-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: The root cause of this bug is a race condition between the onMeasure method and setupReactContext. ReactInstanceManager.attachRootView() method is responsible of the initialization of ReactRootViews and it is invoked by ReactRootView.onMeasure() method in the UIThread Important initialization steps: 1. Clear the Id of the ReactRootView 2. Add the ReactRootView to the mAttachedReactRoots 3. Call StartSurface (if the bridge has been initialized) Sometimes, when this method is invoked for the first time, the bridge is not initialized, in those cases we delay the start of the surface. Once the bridge is initialized, StartSurface is called by the setupReactContext() running in the NativeModuleThread. Since onMeasure can be called multiple times, it is possible that we call "StartSurface" twice for the same ReactRootView, causing the bug reported on T78832286. This diff adds an extra check to prevent calling "StartSurface" twice. The fix is done using an AtomicInteger comparison and it is gated by the flag "enableStartSurfaceRaceConditionFix". Once we verify this works fine in production we will clean up the code, remove the flags and maybe revisit the API of ReactRoot. changelog: [Android] Fix race-condition on the initialization of ReactRootViews Reviewed By: JoshuaGross Differential Revision: D25255877 fbshipit-source-id: ca8fb00f50e86891fb4c5a06240177cc1a0186d9
- Loading branch information
1 parent
dee937c
commit 74a7568
Showing
4 changed files
with
50 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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