Permalink
Browse files

RN catalyst instance destroy markers

Reviewed By: alexeylang

Differential Revision: D6109891

fbshipit-source-id: 2cd1491381220a80f71f9ab205a2c6a309ed35ae
  • Loading branch information...
cwdick authored and facebook-github-bot committed Oct 26, 2017
1 parent f0fb720 commit 1c104310fbd76f3eb9e5ed66865f4671264ace8d
@@ -12,7 +12,6 @@
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 void destroy() {
}
// 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
// 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");
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();
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);
@@ -14,6 +14,8 @@
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,

0 comments on commit 1c10431

Please sign in to comment.