File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
packages/react-native/React/Base Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,7 @@ - (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
313
313
314
314
- (void )dealloc
315
315
{
316
+ RCTBridge *batchedBridge = self.batchedBridge ;
316
317
/* *
317
318
* This runs only on the main thread, but crashes the subclass
318
319
* RCTAssertMainQueue();
@@ -332,7 +333,17 @@ - (void)dealloc
332
333
RCTExecuteOnMainQueue (^{
333
334
facebook::react::jsinspector_modern::getInspectorInstance ().removePage (*inspectorPageId);
334
335
inspectorPageId.reset ();
335
- inspectorTarget.reset ();
336
+ // NOTE: RCTBridgeHostTargetDelegate holds a weak reference to RCTBridge.
337
+ // Conditionally call `inspectorTarget.reset()` to avoid a crash.
338
+ if (batchedBridge) {
339
+ [batchedBridge
340
+ dispatchBlock: ^{
341
+ inspectorTarget.reset ();
342
+ }
343
+ queue: RCTJSThread];
344
+ } else {
345
+ inspectorTarget.reset ();
346
+ }
336
347
});
337
348
}
338
349
}
You can’t perform that action at this time.
0 commit comments