Skip to content

Wake ResizeObserver for native-only layout changes (#60157) - #60157

Merged
meta-codesync[bot] merged 2 commits into
react:mainfrom
rubennorte:export-D133233918
Nov 23, 2026
Merged

meta-codesync[bot] merged 2 commits into
react:mainfrom
rubennorte:export-D133233918

Conversation

@rubennorte

@rubennorte rubennorte commented Nov 19, 2026 •

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

Reviewed By: andrewdacenko

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

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Visual regression

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

ios border/child-clipping-radius/default: Changed, 67645 px (75.161%)

diff

Expected and Captured
Expected Captured
expected captured

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]

Reviewed By: andrewdacenko

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

Reviewed By: andrewdacenko

Differential Revision: D133233918
rubennorte added a commit to rubennorte/react-native that referenced this pull request Nov 23, 2026
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

Reviewed By: andrewdacenko

Differential Revision: D133233918
@meta-codesync meta-codesync Bot changed the title Wake ResizeObserver for native-only layout changes Wake ResizeObserver for native-only layout changes (#60157) Nov 23, 2026
@rubennorte
rubennorte force-pushed the export-D133233918 branch 2 times, most recently from 269e71d to 2d046e3 Compare November 23, 2026 15:04
@meta-codesync
meta-codesync Bot merged commit 250893d into react:main Nov 23, 2026
95 of 96 checks passed
@react-native-bot

Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @rubennorte in 250893d

When will my fix make it into a release? | How to file a pick request?

@react-native-bot react-native-bot added the Merged This PR has been merged. label Nov 23, 2026
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. Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants