From de8293193199f90fd7bc15f084a066cdc34998a8 Mon Sep 17 00:00:00 2001 From: Lukas Piatkowski Date: Wed, 7 Dec 2016 10:29:16 -0800 Subject: [PATCH] Fix SamplingProfiler and HeapCapture for apps that lazy load react modules Reviewed By: cwdick Differential Revision: D4291903 fbshipit-source-id: 684ced8d6370494191cdb182a8e172680d69d17b --- .../java/com/facebook/react/devsupport/JSCHeapCapture.java | 4 +++- .../com/facebook/react/devsupport/JSCSamplingProfiler.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java index 7db70f572..bbc36797f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCHeapCapture.java @@ -22,7 +22,9 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.module.annotations.ReactModule; -@ReactModule(name = "JSCHeapCapture") +// This module is being called only by Java via the static method "captureHeap" that +// requires it to alreay be initialized, thus we eagerly initialize this module +@ReactModule(name = "JSCHeapCapture", needsEagerInit = true) public class JSCHeapCapture extends ReactContextBaseJavaModule { public interface HeapCapture extends JavaScriptModule { void captureHeap(String path); diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java index 4a35aa74d..049f72c32 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java +++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/JSCSamplingProfiler.java @@ -21,7 +21,9 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.module.annotations.ReactModule; -@ReactModule(name = "JSCSamplingProfiler") +// This module is being called only by Java via the static method "poke" that +// requires it to alreay be initialized, thus we eagerly initialize this module +@ReactModule(name = "JSCSamplingProfiler", needsEagerInit = true) public class JSCSamplingProfiler extends ReactContextBaseJavaModule { public interface SamplingProfiler extends JavaScriptModule { void poke(int token);