From 1b4678105b8658fc2551ff1302f909e7001586df Mon Sep 17 00:00:00 2001 From: David Vacca Date: Fri, 10 May 2019 16:26:40 -0700 Subject: [PATCH] Ensures constraintSurfaceLayout is executed before 'JS run application' starts Summary: This diff ensures the method scheduler.constraintSurfaceLayout is executed before the JS run application start. This is necessary to properly set the pointScaleFactor for the Root before running JS. This is a workaround to fix a bug when the pointScaleFactor changes over time for the rootShadowNode. The bug is easily reproducible when rendering the "fabric" indicator on Fabric screens. During the first render of a Fabric screen this method was called before "JS run application" starts, and the Fabric indicator was render correctly. Beacuse of timing of measure APIS, the second time a Fabric screen is rendered the method is called after the "JS run application process started", as a consecuence the Fabric indicator is not rendered correctlly (the pointScaleFactor is incorrectly assigned into the layout metrics of the Fabric indicator text). We still need to analyze why the pointScaleFactor is not correctly assigned when it is set after the "JS run application process started", but this will be part of another diff. Reviewed By: shergin Differential Revision: D15303554 fbshipit-source-id: 7d985cefee20fd40dbe04166c1a1358b3f3ddc85 --- .../src/main/java/com/facebook/react/ReactRootView.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java index 324af3df587..97b594049a3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java @@ -507,7 +507,10 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { // TODO call surface's runApplication } else { - if (mWasMeasured) { + 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) { updateRootLayoutSpecs(mWidthMeasureSpec, mHeightMeasureSpec); } @@ -517,7 +520,7 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot { if (appProperties != null) { appParams.putMap("initialProps", Arguments.fromBundle(appProperties)); } - if (getUIManagerType() == FABRIC) { + if (isFabric) { appParams.putBoolean("fabric", true); }