mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-04 22:56:32 +08:00
properly clean up RN
Reviewed By: javache Differential Revision: D5170608 fbshipit-source-id: 065cf4ba4244c26bf5fdf9f5183a6bb1295676ad
This commit is contained in:
committed by
Facebook Github Bot
parent
df1070b750
commit
37536e93b7
@@ -287,6 +287,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
// TODO: tell all APIs to shut down
|
||||
mDestroyed = true;
|
||||
|
||||
mNativeModulesQueueThread.runOnQueue(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -297,7 +298,14 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
listener.onTransitionToBridgeIdle();
|
||||
}
|
||||
}
|
||||
mHybridData.resetNative();
|
||||
UiThreadUtil.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mHybridData.resetNative();
|
||||
// Kill non-UI threads from UI thread.
|
||||
getReactQueueConfiguration().destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -26,4 +26,5 @@ public interface ReactQueueConfiguration {
|
||||
MessageQueueThread getUIBackgroundQueueThread();
|
||||
MessageQueueThread getNativeModulesQueueThread();
|
||||
MessageQueueThread getJSQueueThread();
|
||||
void destroy();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,10 @@ public class ReactQueueConfigurationImpl implements ReactQueueConfiguration {
|
||||
* is destroyed so that we shut down the proper queue threads.
|
||||
*/
|
||||
public void destroy() {
|
||||
if (mUIBackgroundQueueThread != null &&
|
||||
mUIBackgroundQueueThread.getLooper() != Looper.getMainLooper()) {
|
||||
mUIBackgroundQueueThread.quitSynchronous();
|
||||
}
|
||||
if (mNativeModulesQueueThread.getLooper() != Looper.getMainLooper()) {
|
||||
mNativeModulesQueueThread.quitSynchronous();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user