Skip to content

Wake ResizeObserver for native-only layout changes - #60157

Open
rubennorte wants to merge 2 commits into
react:mainfrom
rubennorte:export-D133233918
Open

rubennorte wants to merge 2 commits into
react:mainfrom
rubennorte:export-D133233918

Conversation

@rubennorte

Copy link
Copy Markdown
Member

Summary:

Context

Native-only layout commits can leave ResizeObserver notifications pending while the JavaScript runtime is idle. Without an onLayout listener, no event task is guaranteed to drive the existing resize-observation rendering step. Commits without dirty observed families should not enqueue extra JS work.

Changes

  • Request a coalesced wake only when the commit reports dirty observed families, using the existing scheduler API and commit-listener contract.
  • Keep the commit hook limited to collecting family identities. All resize computation and reported-size updates stay in the existing JS rendering-step gather/broadcast loop.
  • Keep queued work lifetime-safe across disconnect/reconnect with a per-connection flag captured by the wake task. Document the existing UIManager unregister barrier before connection members are reset.
  • Add native root-resize tests using the preceding Fantom control. Cover idle delivery, ordering before newly scheduled onLayout, coalescing, unobserved surfaces, queued reconnects, and no queued wake without a dirty observed family. Dirty targets whose selected box is unchanged do not produce callbacks. Events queued before observation retain FIFO order.
  • Leave runtime-scheduler implementation, commit-hook infrastructure, and C++ API snapshots unchanged.

Changelog:
[General][Fixed] - Notify ResizeObserver of native layout changes when the JavaScript runtime is idle

Differential Revision: D133233918

Summary:
## Context
Fantom can create roots with a chosen viewport size, but its existing native `TesterAppDelegate::updateSurfaceConstraints` method was not exposed to JavaScript tests. Tests of native host resizing need to change root constraints without another React render or flushing pending JS work.

## Changes
- Add a thin `root.updateSurfaceConstraints(width, height)` binding to the existing tester method, forwarding the root’s device pixel ratio.
- Add root-view tests for growing and shrinking native constraints, percentage-sized descendants, stable host refs, deferred JS work, and attempts to resize a destroyed root.
- Document the control. Do not add context tracking or a queue-validation API.

Changelog: [Internal]

Differential Revision: D133247484
Summary:
## Context
Native-only layout commits can leave `ResizeObserver` notifications pending while the JavaScript runtime is idle. Without an `onLayout` listener, no event task is guaranteed to drive the existing resize-observation rendering step. Commits without dirty observed families should not enqueue extra JS work.

## Changes
- Request a coalesced wake only when the commit reports dirty observed families, using the existing scheduler API and commit-listener contract.
- Keep the commit hook limited to collecting family identities. All resize computation and reported-size updates stay in the existing JS rendering-step gather/broadcast loop.
- Keep queued work lifetime-safe across disconnect/reconnect with a per-connection flag captured by the wake task. Document the existing UIManager unregister barrier before connection members are reset.
- Add native root-resize tests using the preceding Fantom control. Cover idle delivery, ordering before newly scheduled `onLayout`, coalescing, unobserved surfaces, queued reconnects, and no queued wake without a dirty observed family. Dirty targets whose selected box is unchanged do not produce callbacks. Events queued before observation retain FIFO order.
- Leave runtime-scheduler implementation, commit-hook infrastructure, and C++ API snapshots unchanged.

Changelog:
[General][Fixed] - Notify `ResizeObserver` of native layout changes when the JavaScript runtime is idle

Differential Revision: D133233918
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 19, 2026
@meta-codesync

meta-codesync Bot commented Nov 19, 2026

Copy link
Copy Markdown

@rubennorte has exported this pull request. If you are a Meta employee, you can view the originating Diff in D133233918.

@andrewdacenko andrewdacenko left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@github-actions

Copy link
Copy Markdown

Visual regression

1 visual difference(s) at 8680e83ae64b. Visual differences need maintainer approval. Review the report, then apply visual-change-approved.

ios touchable/highlight/default: Changed, 42 px (0.039%)

diff

Expected and Captured
Expected Captured
expected captured

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants