Text node shrinks on each layout pass due to bug in YGRoundToPixelGrid #824
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.