Skip to content

Commit b5e9002

Browse files
committed
fix(android): modal crash when destroy root
1 parent 19ea88c commit b5e9002

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/modal/HippyModalHostManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ protected HippyModalHostView createModalHostView(Context context) {
6161
@Override
6262
public void onViewDestroy(HippyModalHostView hippyModalHostView) {
6363
super.onViewDestroy(hippyModalHostView);
64-
int rootId = NativeRendererManager.getRootId(hippyModalHostView.getContext());
65-
hippyModalHostView.onInstanceDestroy(rootId);
64+
hippyModalHostView.onDestroy();
6665
}
6766

6867
@HippyControllerProps(name = "animationType", defaultType = HippyControllerProps.STRING,

renderer/native/android/src/main/java/com/tencent/mtt/hippy/views/modal/HippyModalHostView.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ public void onInstancePause() {
110110

111111
@Override
112112
public void onInstanceDestroy(int rootId) {
113+
dismiss();
114+
}
115+
116+
public void onDestroy() {
113117
if (mNativeRenderer != null) {
114118
mNativeRenderer.removeInstanceLifecycleEventListener(this);
115119
}

renderer/native/android/src/main/java/com/tencent/renderer/NativeRenderer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ public void destroyRoot(int rootId) {
491491
for (HippyInstanceLifecycleEventListener listener : mInstanceLifecycleEventListeners) {
492492
listener.onInstanceDestroy(rootId);
493493
}
494+
mInstanceLifecycleEventListeners.clear();
494495
}
495496
ChoreographerUtils.unregisterDoFrameListener(getInstanceId(), rootId);
496497
mRenderManager.deleteNode(rootId, rootId);

0 commit comments

Comments
 (0)