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
This commit is contained in:
David Vacca
2019-05-10 16:26:40 -07:00
committed by Facebook Github Bot
parent ac9195a506
commit 1b4678105b

View File

@@ -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);
}