Floating precision error causing oversized layout main dimension (totalFlexShrinkScaledFactors) #1783

Open
opened 2025-02-05 17:31:30 -08:00 by Hexlord · 1 comment
Hexlord commented 2025-02-05 17:31:30 -08:00 (Migrated from github.com)

There are cases where subtraction from totalFlexShrinkScaledFactors causes the value to apporach zero but not quite reach it, flexLine.layout.totalFlexShrinkScaledFactors == 0 should instead be <= 0.001
Happens only under extreme conditions (resizing panels to 0 width)

49ee855f99/yoga/algorithm/CalculateLayout.cpp (L659)

There are cases where subtraction from totalFlexShrinkScaledFactors causes the value to apporach zero but not quite reach it, `flexLine.layout.totalFlexShrinkScaledFactors == 0` should instead be <= 0.001 Happens only under extreme conditions (resizing panels to 0 width) https://github.com/facebook/yoga/blob/49ee855f99fb67079c24d507a4ea1b6d80fa2ebf/yoga/algorithm/CalculateLayout.cpp#L659
NickGerleman commented 2025-02-06 12:59:24 -08:00 (Migrated from github.com)

We have yoga::inexactEquals that we could use for this. The way it works is a bit of a sledge hammer, but it's the right overall check here if we can accumulate FP error.

We have `yoga::inexactEquals` that we could use for this. The way it works is a bit of a sledge hammer, but it's the right overall check here if we can accumulate FP error.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#1783
No description provided.