mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Ensure that EventEmitterWrapper is cleaned up as soon as a View is deleted
Summary: In T92179998, there is a crash when an EventEmitterWrapper is deallocated after the JS VM is torn down, and the EventEmitterWrapper tries to free its JSI::Pointer reference (double-free). To make sure this happens less/not at all, free EventEmitterWrappers on ViewState when a view is deleted, instead of waiting for all of RN to be torn down. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D29020768 fbshipit-source-id: 9d72a23bc9966992ef56c1e3ee523405d4333194
This commit is contained in:
committed by
Facebook GitHub Bot
parent
43cf565866
commit
25e8fbe8ff
+8
@@ -813,6 +813,14 @@ public class SurfaceMountingManager {
|
||||
viewState.mStateWrapper = null;
|
||||
}
|
||||
|
||||
// Destroy EventEmitterWrapper immediately instead of waiting for Java GC.
|
||||
// Notably, this is also required to ensure that the EventEmitterWrapper is deallocated
|
||||
// before the JS VM is deallocated, since it holds onto a JSI::Pointer.
|
||||
if (viewState.mEventEmitter != null) {
|
||||
viewState.mEventEmitter.destroy();
|
||||
viewState.mEventEmitter = null;
|
||||
}
|
||||
|
||||
// For non-root views we notify viewmanager with {@link ViewManager#onDropInstance}
|
||||
ViewManager viewManager = viewState.mViewManager;
|
||||
if (!viewState.mIsRoot && viewManager != null) {
|
||||
|
||||
Reference in New Issue
Block a user