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
This commit is contained in:
Emily Janzer
2019-10-07 16:21:26 -07:00
committed by Facebook Github Bot
parent d576a5bcc0
commit b5ea49f132
@@ -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() {