diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java index 3f11e889c..3c65139a7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/CatalystInstanceImpl.java @@ -12,7 +12,6 @@ package com.facebook.react.bridge; import android.content.res.AssetManager; import android.os.AsyncTask; import android.util.Log; - import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.jni.HybridData; @@ -320,35 +319,39 @@ public class CatalystInstanceImpl implements CatalystInstance { } // TODO: tell all APIs to shut down + ReactMarker.logMarker(ReactMarkerConstants.DESTROY_CATALYST_INSTANCE_START); mDestroyed = true; - mNativeModulesQueueThread.runOnQueue(new Runnable() { - @Override - public void run() { - mNativeModuleRegistry.notifyJSInstanceDestroy(); - boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0); - if (!wasIdle && !mBridgeIdleListeners.isEmpty()) { - for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) { - listener.onTransitionToBridgeIdle(); - } - } - AsyncTask.execute(new Runnable() { + mNativeModulesQueueThread.runOnQueue( + new Runnable() { @Override public void run() { - // Kill non-UI threads from neutral third party - // potentially expensive, so don't run on UI thread + mNativeModuleRegistry.notifyJSInstanceDestroy(); + boolean wasIdle = (mPendingJSCalls.getAndSet(0) == 0); + if (!wasIdle && !mBridgeIdleListeners.isEmpty()) { + for (NotThreadSafeBridgeIdleDebugListener listener : mBridgeIdleListeners) { + listener.onTransitionToBridgeIdle(); + } + } + AsyncTask.execute( + new Runnable() { + @Override + public void run() { + // Kill non-UI threads from neutral third party + // potentially expensive, so don't run on UI thread - // contextHolder is used as a lock to guard against other users of the JS VM having - // the VM destroyed underneath them, so notify them before we resetNative - mJavaScriptContextHolder.clear(); + // contextHolder is used as a lock to guard against other users of the JS VM having + // the VM destroyed underneath them, so notify them before we resetNative + mJavaScriptContextHolder.clear(); - mHybridData.resetNative(); - getReactQueueConfiguration().destroy(); - Log.d(ReactConstants.TAG, "CatalystInstanceImpl.destroy() end"); + mHybridData.resetNative(); + getReactQueueConfiguration().destroy(); + Log.d(ReactConstants.TAG, "CatalystInstanceImpl.destroy() end"); + ReactMarker.logMarker(ReactMarkerConstants.DESTROY_CATALYST_INSTANCE_END); + } + }); } }); - } - }); // This is a noop if the listener was not yet registered. Systrace.unregisterListener(mTraceListener); diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java index d5d836178..0e0ecccef 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java @@ -14,6 +14,8 @@ public enum ReactMarkerConstants { BUILD_NATIVE_MODULE_REGISTRY_END, CREATE_CATALYST_INSTANCE_START, CREATE_CATALYST_INSTANCE_END, + DESTROY_CATALYST_INSTANCE_START, + DESTROY_CATALYST_INSTANCE_END, RUN_JS_BUNDLE_START, RUN_JS_BUNDLE_END, NATIVE_MODULE_INITIALIZE_START,