Call stopSurface when ReactRootView is unregistered

Summary:
In the past, in Fabric (Android), we never called stopSurface. Ever! This is bad for memory and can cause other issues, so... let's not do that.

Instead, when the ReactRootView is being torn down, we check the View ID to see if it's a Fabric RootView, and if it is, we call Fabric's stopSurface method.

Fabric stopSurface only has impact on (1) Fabric mount instructions being executed after that point and (2) tells JS to stop running the surface, on the JS thread, asynchronously.

Anecdotally it looks like all the MountItems involved in deleting and removing views from the hierarchy are executed before stopSurface is called.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D21965837

fbshipit-source-id: 5169c5a1e339fd9e016ae1234d8389b2bd30be70
This commit is contained in:
Joshua Gross authored and Facebook GitHub Bot committed 2020-06-09 23:23:10 -07:00
1 parent 1c92b1cff6
commit 03174f1cad
4 files changed
+30

No files matched your search

@@ -437,6 +437,11 @@ public class UIManagerModule extends ReactContextBaseJavaModule
throw new UnsupportedOperationException();
}
@Override
public void stopSurface(final int surfaceId) {
throw new UnsupportedOperationException();
}
/** Unregisters a new root view. */
@ReactMethod
public void removeRootView(int rootViewTag) {