-
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
Layout bug caused by floating point rounding error #749
Comments
I think this problem is the same as mine: |
how about |
@LeoSchleicher It appears so. |
@linqingmo I've tried to set |
You might want to try with these changes : #688 |
@jmaurice-unity It's not related, #688 is about bug when rounding negative numbers, my coordinates are all positive. |
Can I set YGConfigSetPointScaleFactor outside of Yoga sources? How to get globalConfig? |
I believe I am running into this issue as well. If I set the |
我尝试了一下,字符串后面加一个空格可以解决 😅 |
Report
Issues and Steps to Reproduce
Expected Behavior
The text on the label should be displayed without problem
Actual Behavior
The text got truncated.
Link to Code
Example project to reproduce the issue https://github.com/leafduo/yoga-rounding
The problem was caused by the accumulation of floating point rounding error in complex layout. The view tree in the example has a height of 4, and causes floating point rounding errors to accumulate. In
YGRoundValueToPixelGrid
, thefractial
variable is 0.999877929 and is considered not a whole integer. In the end, the width of the label is one pixel short, causing the text truncation.This issue is presented when
pointScaleFactor
is 3 (not 1 or 2), and perhaps it's because 1) 3 is bigger and will cause more error, and 2) multiply and division by 2 is pretty accurate because the binary nature of computer.Using
double
instead offloat
to represent points, or raising the threshold inYGFloatsEqual
will make the text fully displayed in the example, but not solve this problem completely. It will still exist in a more complex layout.I think maybe we can store scaled value or use a real fraction representation?
The text was updated successfully, but these errors were encountered: