feat(android): add unstable_Immediate UpdateMode for synchronous state updates #56311
Open
intergalacticspacehighway wants to merge 1 commit intofacebook:mainfrom
Open
Conversation
|
Warning JavaScript API change detected This PR commits an update to
This change was flagged as: |
27e92a7 to
f58bfe2
Compare
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:
Currently we support unstable_Immediate mode on
updateStatefor iOS. This allows us to dispatch synchronous shadow node size updates in Expo UI SwiftUI (communicating SwiftUI children size to Yoga. Host for more details).Since it is not enabled on android, it leads to layout shift when mixing Compose and React Native components as Compose tree currently dispatches size information asynchronously to the shadow node.
Here, the video demonstrates the asynchronous vs synchronous
updateStateusage (before and after applying the changes in this PR). Repro linkScreen.Recording.2026-04-02.at.8.52.27.PM.mov
More:
After enabling the
update_immediate, I noticed the flicker was still happening. The issue is that update layout instruction triggers a follow up instruction when we set the shadow node size from Expo UI which gets skipped to the next frame. This is handled on iOS using_followUpTransactionRequiredflag here. This seems to be added on iOS for similar reasons here when dispatching an instruction can lead to a follow-up instruction when synchronous update is triggered. So we also handle the sync follow up transaction in this PR using similar approach to iOS's.Changelog:
[ANDROID] [ADDED] - Add
unstable_ImmediateUpdateMode support inupdateState.Test Plan:
Tested the changes in the repro. Also tested RN Tester, it should be a non breaking change.