-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text node shrinks on each layout pass due to bug in YGRoundToPixelGrid #824
Comments
rigdern
pushed a commit
to rigdern/css-layout
that referenced
this issue
Oct 9, 2018
`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see facebook#824. Adam Comella Microsoft Corp.
rigdern
pushed a commit
to rigdern/css-layout
that referenced
this issue
Oct 9, 2018
`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see facebook#824. Adam Comella Microsoft Corp.
rigdern
pushed a commit
to rigdern/css-layout
that referenced
this issue
Oct 9, 2018
`YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see facebook#824. Fixes facebook#824 Adam Comella Microsoft Corp.
facebook-github-bot
pushed a commit
to facebook/litho
that referenced
this issue
Oct 12, 2018
Summary: `YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see facebook/yoga#824. Fixes #824 Adam Comella Microsoft Corp. Pull Request resolved: facebook/yoga#825 Reviewed By: priteshrnandgaonkar Differential Revision: D10282064 Pulled By: shergin fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
facebook-github-bot
pushed a commit
to facebook/react-native
that referenced
this issue
Oct 12, 2018
Summary: `YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see facebook/yoga#824. Fixes #824 Adam Comella Microsoft Corp. Pull Request resolved: facebook/yoga#825 Reviewed By: priteshrnandgaonkar Differential Revision: D10282064 Pulled By: shergin fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
t-nanava
pushed a commit
to microsoft/react-native-macos
that referenced
this issue
Jun 17, 2019
Summary: `YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see facebook/yoga#824. Fixes #824 Adam Comella Microsoft Corp. Pull Request resolved: facebook/yoga#825 Reviewed By: priteshrnandgaonkar Differential Revision: D10282064 Pulled By: shergin fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
CodeWitchBella
pushed a commit
to CodeWitchBella/yoga-wasm
that referenced
this issue
Sep 2, 2019
Summary: `YGRoundValueToPixelGrid` currently rounds negative numbers incorrectly. For example: ``` YGRoundValueToPixelGrid(-2.2, 1.0, /* ceil */ false, /* floor */ true) = -2.0 ``` However, that operation is supposed to take the floor of the number so the result should acutally be `-3.0`. There's a detailed comment in `YGRoundValueToPixelGrid` about the fix and why it works. A symptom that manifested because of this bug is that text nodes could get smaller and smaller on each layout pass. For details see facebook/yoga#824. Fixes #824 Adam Comella Microsoft Corp. Pull Request resolved: facebook/yoga#825 Reviewed By: priteshrnandgaonkar Differential Revision: D10282064 Pulled By: shergin fbshipit-source-id: 16ca966e6cb0cfc88b1dbf4ba31e7b1dbe1f2049
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Repro
If you run this program:
you'll see this output:
Unexpected result: On each layout pass
node1's
height shrinks even though the input tree hasn't changed in a way that should affectnode1's
height.Analysis
There seem to be a couple of factors that make this bug possible:
YGRoundToPixelGrid
in the previous layout pass is used as input toYGRoundToPixelGrid
in the next layout pass. Consequently, the input to the layout pass is different enabling us to get a different result.0.5
on each layout pass.Here's an example of the bug in
YGRoundToPixelGrid
in action.YGRoundToPixelGrid
has this expression:Let's simplify it to:
And we'll use
Round(x)
to meanYGRoundValueToPixelGrid(x, ...)
(the rest ofYGRoundValueToPixelGrid's
arguments are omitted fromRound
to make it easier to focus on the important stuff for this bug). So the expression becomes:Layout pass 1
Now suppose that we have the following
YGRoundToPixelGrid
variables:Then
roundedNodeHeight
is:So the input node height was
10
and the output is9.5
which is also used as input for the next layout pass.Layout pass 2
Then
roundedNodeHeight
is:So the input node height was
9.5
and the output is9.0
.In this way, each layout pass will decrease the node's height by
0.5
.Adam Comella
Microsoft Corp.
The text was updated successfully, but these errors were encountered: