mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Use startSurface on Android
Summary: We currently have two different codepaths for actually rendering a surface with Fabric on iOS and Android: on iOS we use Fabric's `UIManagerBinding.startSurface` to call `AppRegistry.runApplication`, but on Android we don't; instead we use the same codepath as paper, calling `ReactRootView.runApplication`. This diff does a few different things: 1. Unify iOS and Android by removing the `#ifndef` for Android so that we call `startSurface` for both 2. Pass through the JS module name on Android so that this actually works (it currently passes in an empty string) 3. Remove the call to `ReactRootView.runApplication` for Fabric so that we don't end up doing this twice 4. Copy over some logic that we need from `ReactRootView.runApplication` (make sure that root layout specs get updated, and that content appeared gets logged) Reviewed By: mdvacca Differential Revision: D15501666 fbshipit-source-id: 5c96c8cf036261cb99729b1dbdff0f7c09a32d76
This commit is contained in:
committed by
Facebook Github Bot
parent
ab1a42762c
commit
298f59c5d3
@@ -405,6 +405,21 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidthMeasureSpec() {
|
||||
return mWidthMeasureSpec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeightMeasureSpec() {
|
||||
return mHeightMeasureSpec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldLogContentAppeared(boolean shouldLogContentAppeared) {
|
||||
mShouldLogContentAppeared = shouldLogContentAppeared;
|
||||
}
|
||||
|
||||
private void updateRootLayoutSpecs(final int widthMeasureSpec, final int heightMeasureSpec) {
|
||||
if (mReactInstanceManager == null) {
|
||||
FLog.w(
|
||||
@@ -461,7 +476,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
mRootViewEventListener = eventListener;
|
||||
}
|
||||
|
||||
/* package */ String getJSModuleName() {
|
||||
@Override
|
||||
public String getJSModuleName() {
|
||||
return Assertions.assertNotNull(mJSModuleName);
|
||||
}
|
||||
|
||||
@@ -506,11 +522,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
if (mUseSurface) {
|
||||
// TODO call surface's runApplication
|
||||
} else {
|
||||
|
||||
boolean isFabric = getUIManagerType() == FABRIC;
|
||||
// Fabric requires to call updateRootLayoutSpecs before starting JS Application,
|
||||
// this ensures the root will hace the correct pointScaleFactor.
|
||||
if (mWasMeasured || isFabric) {
|
||||
if (mWasMeasured) {
|
||||
updateRootLayoutSpecs(mWidthMeasureSpec, mHeightMeasureSpec);
|
||||
}
|
||||
|
||||
@@ -520,9 +532,6 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
|
||||
if (appProperties != null) {
|
||||
appParams.putMap("initialProps", Arguments.fromBundle(appProperties));
|
||||
}
|
||||
if (isFabric) {
|
||||
appParams.putBoolean("fabric", true);
|
||||
}
|
||||
|
||||
mShouldLogContentAppeared = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user