Commit d792121 1 parent 98165a2 commit d792121 Copy full SHA for d792121
File tree 5 files changed +22
-4
lines changed
ReactAndroid/src/main/java/com/facebook/react
5 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 8
8
package com .facebook .react .bridge ;
9
9
10
10
import com .facebook .infer .annotation .Assertions ;
11
+ import com .facebook .react .config .ReactFeatureFlags ;
11
12
import java .util .HashMap ;
12
13
import java .util .List ;
13
14
import java .util .Map ;
@@ -44,6 +45,8 @@ public void notifyJSInstanceDestroy() {
44
45
JSIModuleHolder moduleHolder = entry .getValue ();
45
46
moduleHolder .notifyJSInstanceDestroy ();
46
47
}
47
- mModules .clear ();
48
+ if (ReactFeatureFlags .enableReactContextCleanupFix ) {
49
+ mModules .clear ();
50
+ }
48
51
}
49
52
}
Original file line number Diff line number Diff line change 8
8
package com .facebook .react .bridge ;
9
9
10
10
import com .facebook .infer .annotation .Assertions ;
11
+ import com .facebook .react .config .ReactFeatureFlags ;
11
12
import com .facebook .react .module .annotations .ReactModule ;
12
13
import com .facebook .systrace .Systrace ;
13
14
import java .util .ArrayList ;
@@ -84,7 +85,9 @@ private ReactApplicationContext getReactApplicationContext() {
84
85
for (ModuleHolder module : mModules .values ()) {
85
86
module .destroy ();
86
87
}
87
- mModules .clear ();
88
+ if (ReactFeatureFlags .enableReactContextCleanupFix ) {
89
+ mModules .clear ();
90
+ }
88
91
} finally {
89
92
Systrace .endSection (Systrace .TRACE_TAG_REACT_JAVA_BRIDGE );
90
93
}
Original file line number Diff line number Diff line change 23
23
import com .facebook .react .bridge .queue .ReactQueueConfiguration ;
24
24
import com .facebook .react .common .LifecycleState ;
25
25
import com .facebook .react .common .ReactConstants ;
26
+ import com .facebook .react .config .ReactFeatureFlags ;
26
27
import java .lang .ref .WeakReference ;
27
28
import java .util .concurrent .CopyOnWriteArraySet ;
28
29
@@ -296,6 +297,11 @@ public void destroy() {
296
297
if (mCatalystInstance != null ) {
297
298
mCatalystInstance .destroy ();
298
299
}
300
+ if (ReactFeatureFlags .enableReactContextCleanupFix ) {
301
+ mLifecycleEventListeners .clear ();
302
+ mActivityEventListeners .clear ();
303
+ mWindowFocusEventListeners .clear ();
304
+ }
299
305
}
300
306
301
307
/** Should be called by the hosting Fragment in {@link Fragment#onActivityResult} */
Original file line number Diff line number Diff line change @@ -62,4 +62,7 @@ public class ReactFeatureFlags {
62
62
63
63
/** Enables Static ViewConfig in RN Android native code. */
64
64
public static boolean enableExperimentalStaticViewConfigs = false ;
65
+
66
+ /** Enables a more aggressive cleanup during destruction of ReactContext */
67
+ public static boolean enableReactContextCleanupFix = false ;
65
68
}
Original file line number Diff line number Diff line change @@ -247,8 +247,11 @@ public void onCatalystInstanceDestroy() {
247
247
mEventDispatcher .onCatalystInstanceDestroyed ();
248
248
mUIImplementation .onCatalystInstanceDestroyed ();
249
249
250
- getReactApplicationContext ().removeLifecycleEventListener (this );
251
- getReactApplicationContext ().unregisterComponentCallbacks (mMemoryTrimCallback );
250
+ ReactApplicationContext reactApplicationContext = getReactApplicationContext ();
251
+ if (ReactFeatureFlags .enableReactContextCleanupFix ) {
252
+ reactApplicationContext .removeLifecycleEventListener (this );
253
+ }
254
+ reactApplicationContext .unregisterComponentCallbacks (mMemoryTrimCallback );
252
255
YogaNodePool .get ().clear ();
253
256
ViewManagerPropertyUpdater .clear ();
254
257
}
You can’t perform that action at this time.
0 commit comments