Repository navigation
Initialize UIManagerBinding::currentEventPriority_ to Default - #60174
biitran0204-spec wants to merge 1 commit into
Conversation
The field had no initializer and the constructor does not set it, so unstable_getCurrentEventPriority returned uninitialized memory until the first event was dispatched. React reads it when the app first calls updateContainer, so the first render could get an arbitrary lane, sometimes IdleLane. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@javache has imported this pull request. If you are a Meta employee, you can view this in D133523400. |
christophpurrer
left a comment
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
Summary:
UIManagerBinding::currentEventPriority_has no initializer, and the constructor (UIManagerBinding(std::shared_ptr<UIManager>)) doesn't set it. The field is only written insidedispatchEvent. Until the first native event is dispatched,nativeFabricUIManager.unstable_getCurrentEventPriority()returns whatever was in that memory.React's Fabric renderer reads it in
resolveUpdatePriority()whenAppRegistry.runApplicationcallsupdateContainer. So the app's first render gets an arbitrary lane:DefaultEventPriority, as expected.1givesDiscreteEventPriority, a sync render.3givesIdleEventPriority. React then renders the whole first pass in time slices on IdleLane, which never expires, and promise callbacks started during that render run before it commits.How we found it. In an Expo app (RN 0.86.3, New Architecture, Android emulator), we logged
fabricGetCurrentEventPriority()and the lane insideupdateContainer:1702129263on some and0on others.268435456(IdleLane) for the root's first render.NavigationContainerset state from its initial-URL promise before it had mounted, and React warned "Can't perform a React state update on a component that hasn't mounted yet".The declaration is unchanged on
main.Change: initialize the field to
ReactEventPriority::Default, which is also the valuedispatchEventrestores after each event.Changelog:
[GENERAL] [FIXED] - Initialize
UIManagerBinding's current event priority, so an app's first render no longer takes an arbitrary priority (sometimes IdleLane)Test Plan:
UIManagerBinding::dispatchEvent(set to the event's priority, then reset toDefault) and read only byunstable_getCurrentEventPriority. With the initializer, the read before any event returnsDefault, matching what it returns between events.ReactFabric-dev.js'supdateContainer:3(Idle) gives that lane.🤖 Generated with Claude Code