Skip to content

Commit cb8b656

Browse files
idefacebook-github-bot-9
authored andcommitted
Only handle accessibility notifications from the correct RCTAccessibilityManager
Summary: When you reload and create a new bridge, one of the things that happens during setup is that the RCTAccessibilityManager fires a notification. The old bridge would receive this notification from the new bridge's RCTAccessibilityManager, which we don't want, especially because the two are running on different shadow queues. I believe this led to a gnarly crash in NSConcreteTextStorage because RCTMeasure in RCTShadowText.m was getting called for the old RCTText (getting destroyed) from a notification fired from the new shadow queue. The fix is for the UIManager to handle notifications only from its bridge's RCTAccessibilityManager. See #2001 for the kinds of crashes we were seeing. Closes react/react-native#3279 Reviewed By: @​svcscm Differential Revision: D2521652 Pulled By: @nicklockwood fb-gh-sync-id: a4ffe3ef8304667727e573e2a2e8b716e1d2f3e1
1 parent 34c26f3 commit cb8b656

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

React/Modules/RCTUIManager.m

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -229,20 +229,10 @@ - (instancetype)init
229229
_rootViewTags = [NSMutableSet new];
230230

231231
_bridgeTransactionListeners = [NSMutableSet new];
232-
233-
[[NSNotificationCenter defaultCenter] addObserver:self
234-
selector:@selector(didReceiveNewContentSizeMultiplier)
235-
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
236-
object:nil];
237232
}
238233
return self;
239234
}
240235

241-
- (void)dealloc
242-
{
243-
[[NSNotificationCenter defaultCenter] removeObserver:self];
244-
}
245-
246236
- (void)didReceiveNewContentSizeMultiplier
247237
{
248238
__weak RCTUIManager *weakSelf = self;
@@ -276,6 +266,8 @@ - (void)invalidate
276266
[_pendingUIBlocksLock lock];
277267
_pendingUIBlocks = nil;
278268
[_pendingUIBlocksLock unlock];
269+
270+
[[NSNotificationCenter defaultCenter] removeObserver:self];
279271
});
280272
}
281273

@@ -296,6 +288,11 @@ - (void)setBridge:(RCTBridge *)bridge
296288
}
297289

298290
_componentDataByName = [componentDataByName copy];
291+
292+
[[NSNotificationCenter defaultCenter] addObserver:self
293+
selector:@selector(didReceiveNewContentSizeMultiplier)
294+
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
295+
object:_bridge.accessibilityManager];
299296
}
300297

301298
- (dispatch_queue_t)methodQueue

0 commit comments

Comments
 (0)