react / react/yoga

Floating precision error causing oversized layout main dimension (totalFlexShrinkScaledFactors)

Open
#1,783 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
18.9k
Forks
1.6k
Avg merge
1m
Merged PRs (30d)
1

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in yoga/algorithm/CalculateLayout.cpp at the linked line and inspect how totalFlexShrinkScaledFactors is checked after subtraction. Reproduce the extreme panel-resizing case that reaches zero width, then verify that the resulting layout no longer gets an oversized main dimension when the value is near zero.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.