Repository navigation
Conversation
`setNativeProps` commits synchronously, but JS layout reads use the revision captured for the task, and only React's commits refresh it. So a read, then `setNativeProps`, then a read in the same task returns the old layout. JS-driven Animated on Fabric applies its values with `setNativeProps`, so it's affected the same way. `ResizeObserver` gathers against the same revision, so a resize that a callback makes with `setNativeProps` isn't delivered for a deeper target until the surface next commits. This adds an overload of `setNativeProps_DEPRECATED` for JS, which refreshes the captured revision after a successful commit, as `completeSurface` does. It takes the runtime only to ensure it runs on the JS thread, as `EventTarget::release` does. Both JS entry points, `NativeDOM` and `nativeFabricUIManager`, use it. The existing overload, which nothing else in this repo calls, keeps its behavior for native callers, so a call from another thread still can't change what JS sees partway through a task. It now returns the commit status, so that a cancelled commit doesn't refresh anything. A `ResizeObserver` callback that resizes an observed target no deeper than the shallowest one delivered in that round, such as its own target, now gets the spec's loop error, logged with `console.error`. When that target is delivered doesn't change: it still waits for the surface's next commit. With commit branching and a React revision pending, later reads and `ResizeObserver` see React's revision, which doesn't include the call. Neither does the tree that the merge mounts, until the node is next cloned and its stored props are applied again. Changelog: [General][Fixed] - Layout reads see earlier `setNativeProps` calls in the same task, including JS-driven Animated updates
Collaborator
Author
|
FYI - This is part of an effort to make #60355 a cleaner architectural fit - it's one of a few smaller foundational changes, each one a self-contained fix, and should be easier to validate. |
robhogan
marked this pull request as ready for review
December 1, 2026 16:38
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
JS layout reads use the shadow tree revision captured for the task, so that a UI-thread commit partway through a task doesn't change what they see.
completeSurfacerefreshes that revision after React commits, butsetNativePropsdoesn't, so a read, thensetNativeProps, then a read in the same task returns the old layout. That includes JS-driven Animated, which applies its values withsetNativeProps.This adds an overload of
setNativeProps_DEPRECATEDfor JS that refreshes the captured revision after a successful commit, ascompleteSurfacedoes. It takes the runtime just to ensure it's on the JS thread, asEventTarget::releasedoes, and both JS entry points (NativeDOMandnativeFabricUIManager) use it. Native callers keep the existing overload, so a commit from another thread still can't change what JS sees mid-task.With
ResizeObserverenabled, a resize that a callback makes withsetNativePropsis now delivered for deeper targets in the same update, rather than at the surface's next commit. A callback that resizes its own target (or anything no deeper than the targets just delivered) now gets the spec's loop error in the console.With commit branching and a React revision pending, reads still see React's revision, which doesn't include the call. Neither does the tree the merge mounts, until the node is next cloned.
Changelog:
[GENERAL] [FIXED] - Layout reads see earlier
setNativePropscalls in the same task, including JS-driven Animated updatesTest Plan:
New Fantom tests for read →
setNativeProps→ read through both entry points, for a deeperResizeObservertarget resized from a callback in the same update, and for the loop error. All three fail without this change, with commit branching on and off.The refresh costs ~45ns per call. In an AI-driven Fantom benchmark of 100
setNativePropscalls per task (optimised tester build, 10 interleaved runs), it's within noise ofmain.