mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Refactor MountingManager into MountingManager + SurfaceMountingManager
Summary: This refactors MountingManager into a minimal API that shims into a more fully-featured SurfaceMountingManager. The SurfaceMountingManager keeps track of surface start/stop, surface ID, and surface Context. This solves a number of issues around (1) race conditions around StopSurface/StartSurface, (2) memory management of Views, (3) Concrete improvements: 1. Simpler to reason about race conditions around StopSurface/StartSurface. 2. 1:1 relationship between SurfaceId and all Views/tags. 3. When surface is stopped, all descendent Views can be GC'd immediately. 4. Fixed separation of concerns and leaky abstractions: surfaceId/rootTag and Surface Context are now stored and manipulated *only* in SurfaceMountingManager. 5. Simpler StopSurface flow: we simply remove references to all Views, and the Fragment (outside of the scope of this code) removes the RootView. This will trigger GC and we do ~0 work. Previously, we ran a REMOVE and DELETE instruction and kept track of each View in a HashMap. Now we can simply delete the map and move on. The caveat: NativeAnimated (or other native modules that go through UIManager). APIs like `updateProps` currently uses only the ReactTag and does not store SurfaceId. This is a good argument for moving away from ReactTag, at least in its current incarnation, but: for now this requires that you do a lookup of a ReactTag across N surfaces (worst-case) to determine which Surface a ReactTag is in. So, to summarize, the "con" of this approach is that now `getSurfaceManagerForViewEnforced` could be slower. It is used in: * NativeAnimatedModule calls `updateProps` through UIManager * FabricEventEmitter calls `receiveEvent` on FabricUIManager directly * On audit, I could find zero native callsites to `sendAccessibilityEvent` through UIManager Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26000781 fbshipit-source-id: 386ae40c4333f8c584e05818c404868dbee6ce73
This commit is contained in:
committed by
Facebook GitHub Bot
parent
82e9cb1b4e
commit
29eb632f1c
@@ -724,8 +724,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule
|
||||
@ReactMethod
|
||||
public void dispatchViewManagerCommand(
|
||||
int reactTag, Dynamic commandId, @Nullable ReadableArray commandArgs) {
|
||||
// TODO: this is a temporary approach to support ViewManagerCommands in Fabric until
|
||||
// the dispatchViewManagerCommand() method is supported by Fabric JS API.
|
||||
// Fabric dispatchCommands should go through the JSI API - this will crash in Fabric.
|
||||
@Nullable
|
||||
UIManager uiManager =
|
||||
UIManagerHelper.getUIManager(
|
||||
|
||||
Reference in New Issue
Block a user