From b5ea49f132ef58c0cb5061dead6cdc137780c7e1 Mon Sep 17 00:00:00 2001 From: Emily Janzer Date: Mon, 7 Oct 2019 16:21:26 -0700 Subject: [PATCH] Move sDidInit to the end of ReactBridge.staticInit() Summary: Oleksandr made the point that making `sDidInit` volatile isn't quite enough because the flag is set at the beginning of the function; it's possible that it will return true while it's still in the process of initializing the bridge. Moving where we set the flag to the end of the function should address the issue. Reviewed By: JoshuaGross Differential Revision: D17770128 fbshipit-source-id: 695d3edc582d9dce1884d8698d400dd147ca5cae --- .../src/main/java/com/facebook/react/bridge/ReactBridge.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java index ec7f09d633d..4b16e586afc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactBridge.java @@ -26,8 +26,6 @@ public class ReactBridge { if (sDidInit) { return; } - sDidInit = true; - sLoadStartTime = SystemClock.uptimeMillis(); Systrace.beginSection( TRACE_TAG_REACT_JAVA_BRIDGE, "ReactBridge.staticInit::load:reactnativejni"); @@ -36,6 +34,7 @@ public class ReactBridge { ReactMarker.logMarker(ReactMarkerConstants.LOAD_REACT_NATIVE_SO_FILE_END); Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE); sLoadEndTime = SystemClock.uptimeMillis(); + sDidInit = true; } public static long getLoadStartTime() {