mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Try to call setSurfaceId and setId earlier on ReactRootViews
Summary: We assume that startSurface is always called off the UI thread; see if we can synchronously call setId and setSurfaceId, and in general, call setSurfaceId sooner. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D26053050 fbshipit-source-id: a657584502bb0018e9591fe610eac0fc9fab2ca9
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6b1a899ef7
commit
de8aa2c6b9
+13
-2
@@ -29,6 +29,7 @@ import com.facebook.react.common.build.ReactBuildConfig;
|
||||
import com.facebook.react.fabric.events.EventEmitterWrapper;
|
||||
import com.facebook.react.touch.JSResponderHandler;
|
||||
import com.facebook.react.uimanager.IllegalViewOperationException;
|
||||
import com.facebook.react.uimanager.ReactRoot;
|
||||
import com.facebook.react.uimanager.ReactStylesDiffMap;
|
||||
import com.facebook.react.uimanager.RootView;
|
||||
import com.facebook.react.uimanager.RootViewManager;
|
||||
@@ -136,7 +137,7 @@ public class SurfaceMountingManager {
|
||||
// Since this is called from the constructor, we know the surface cannot have stopped yet.
|
||||
mTagToViewState.put(mSurfaceId, new ViewState(mSurfaceId, rootView, mRootViewManager, true));
|
||||
|
||||
UiThreadUtil.runOnUiThread(
|
||||
Runnable runnable =
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -158,8 +159,18 @@ public class SurfaceMountingManager {
|
||||
+ "explicitly overwrite the id field to View.NO_ID before calling addRootView.");
|
||||
}
|
||||
rootView.setId(mSurfaceId);
|
||||
|
||||
if (rootView instanceof ReactRoot) {
|
||||
((ReactRoot) rootView).setRootViewTag(mSurfaceId);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (UiThreadUtil.isOnUiThread()) {
|
||||
runnable.run();
|
||||
} else {
|
||||
UiThreadUtil.runOnUiThread(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user