Reland Fix possible invalid measurements when width or height is zero pixels #1823

Closed
NickGerleman wants to merge 1 commits from export-D76851589 into main
NickGerleman commented 2025-06-30 19:45:19 -07:00 (Migrated from github.com)

Summary:
Fixes https://github.com/facebook/yoga/issues/1819

Yoga has a fast path when measuring a node, if it thinks it knows its dimensions ahead of time.

This path has some eroneous logic, to set both axis to owner size, if either will evaluate to zero, while having an YGMeasureModeAtMost/FitContent constraint. This means that if a node is given a zero width, and Yoga later measures with with FitContent, its height will become the maximum allowable height, even if it shouldn't be that large.

We can fix this, by only allowing if both axis are this fixed case, instead of just one.

This bug has existed for about a decade (going back to at least D3312496).

Changelog:
[General][Fixed] - Fix possible invalid measurements with width or height is zero pixels

Reviewed By: yungsters

Differential Revision: D76851589

Summary: Fixes https://github.com/facebook/yoga/issues/1819 Yoga has a fast path when measuring a node, if it thinks it knows its dimensions ahead of time. This path has some eroneous logic, to set both axis to owner size, if *either* will evaluate to zero, while having an `YGMeasureModeAtMost`/`FitContent` constraint. This means that if a node is given a zero width, and Yoga later measures with with `FitContent`, its height will become the maximum allowable height, even if it shouldn't be that large. We can fix this, by only allowing if both axis are this fixed case, instead of just one. This bug has existed for about a decade (going back to at least D3312496). Changelog: [General][Fixed] - Fix possible invalid measurements with width or height is zero pixels Reviewed By: yungsters Differential Revision: D76851589
vercel[bot] commented 2025-06-30 19:45:24 -07:00 (Migrated from github.com)

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
yoga-website Ready (Inspect) Visit Preview 💬 Add feedback Jul 1, 2025 2:47am
[vc]: #pe1i4PIoqN7pclBs9JK96gntwVAalR2c737vRbH9jBs=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJ5b2dhLXdlYnNpdGUiLCJyb290RGlyZWN0b3J5Ijoid2Vic2l0ZSIsImluc3BlY3RvclVybCI6Imh0dHBzOi8vdmVyY2VsLmNvbS9mYm9wZW5zb3VyY2UveW9nYS13ZWJzaXRlLzZCQXMxY3RHQlVXOE42cGUxaUtGVHhxWkFxck4iLCJwcmV2aWV3VXJsIjoieW9nYS13ZWJzaXRlLWdpdC1mb3JrLW5pY2tnZXJsZW1hbi1leHBvcnQtZC1mMzc3MjYtZmJvcGVuc291cmNlLnZlcmNlbC5hcHAiLCJuZXh0Q29tbWl0U3RhdHVzIjoiREVQTE9ZRUQiLCJsaXZlRmVlZGJhY2siOnsicmVzb2x2ZWQiOjAsInVucmVzb2x2ZWQiOjAsInRvdGFsIjowLCJsaW5rIjoieW9nYS13ZWJzaXRlLWdpdC1mb3JrLW5pY2tnZXJsZW1hbi1leHBvcnQtZC1mMzc3MjYtZmJvcGVuc291cmNlLnZlcmNlbC5hcHAifX1dfQ== **The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more) | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **yoga-website** | ✅ Ready ([Inspect](https://vercel.com/fbopensource/yoga-website/6BAs1ctGBUW8N6pe1iKFTxqZAqrN)) | [Visit Preview](https://yoga-website-git-fork-nickgerleman-export-d-f37726-fbopensource.vercel.app) | 💬 [**Add feedback**](https://vercel.live/open-feedback/yoga-website-git-fork-nickgerleman-export-d-f37726-fbopensource.vercel.app?via=pr-comment-feedback-link) | Jul 1, 2025 2:47am |
facebook-github-bot commented 2025-06-30 19:45:28 -07:00 (Migrated from github.com)

This pull request was exported from Phabricator. Differential Revision: D76851589

This pull request was **exported** from Phabricator. Differential Revision: [D76851589](https://www.internalfb.com/diff/D76851589)
facebook-github-bot commented 2025-06-30 20:50:30 -07:00 (Migrated from github.com)

This pull request has been merged in facebook/yoga@4b5ca50117.

This pull request has been merged in facebook/yoga@4b5ca501176c1cb59a6cdca731da4fb62edb736f.

Pull request closed

Sign in to join this conversation.
No description provided.