Skip to content

Commit

Permalink
Only handle accessibility notifications from the correct RCTAccessibi…
Browse files Browse the repository at this point in the history
…lityManager

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 #3279

Reviewed By: @​svcscm

Differential Revision: D2521652

Pulled By: @nicklockwood

fb-gh-sync-id: a4ffe3ef8304667727e573e2a2e8b716e1d2f3e1
  • Loading branch information
ide authored and facebook-github-bot-9 committed Oct 8, 2015
1 parent 34c26f3 commit cb8b656
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,10 @@ - (instancetype)init
_rootViewTags = [NSMutableSet new];

_bridgeTransactionListeners = [NSMutableSet new];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveNewContentSizeMultiplier)
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
object:nil];
}
return self;
}

- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)didReceiveNewContentSizeMultiplier
{
__weak RCTUIManager *weakSelf = self;
Expand Down Expand Up @@ -276,6 +266,8 @@ - (void)invalidate
[_pendingUIBlocksLock lock];
_pendingUIBlocks = nil;
[_pendingUIBlocksLock unlock];

[[NSNotificationCenter defaultCenter] removeObserver:self];
});
}

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

_componentDataByName = [componentDataByName copy];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didReceiveNewContentSizeMultiplier)
name:RCTAccessibilityManagerDidUpdateMultiplierNotification
object:_bridge.accessibilityManager];
}

- (dispatch_queue_t)methodQueue
Expand Down

0 comments on commit cb8b656

Please sign in to comment.