Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fabric: Fixed a crash caused by calling
[RCTFabricSurface start]
of…
…f the main thread Summary: We need to register a root view component here synchronously because right after we start a surface, it can initiate an update that can query the root component. This fixes an issue in Fabric Surface caused by a data race between registration of root component and concurrent call to `constraintLayout` on the main thread. This how it happens: 1. We call `startSurface` on some background thread; 2. As a result `[RCTFabricSurface start]` schedules a lambda to the main thread that will register a root component. 3. Meanwhile some other code on the main thread changes the layout and requests the relayout of a surface. 4. Because the surface is already running, the `constraintLayout` method works as expected and schedules a mutation instruction that changes the size of the root component. 5. The mutation instruction is being delivered synchronously on the main thread and fails because the root component was not yet registered. Boom. For now, it's not fully clear how to solve this problem properly. I suspect that the good solution would be to shift the responsibility of registering a root component to the MountingCoordinator side (so, we will have an explicit instruction prescribing creating and registering the root component). This will probably be a quite invasive change though. For now, I think it's fine to make the block synchronous to avoid the race. Reviewed By: mdvacca Differential Revision: D26802418 fbshipit-source-id: d49484c90d1ac61ac595caf486562fc6f4843e2f
- Loading branch information