From 42eb955d8fae41fe1650a72e35222aa49166fcaf Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Mon, 3 Apr 2017 09:57:16 -0700 Subject: [PATCH] Range controller: do not schedule range update after rendering finishes if already in full range mode (#3236) --- Source/Details/ASRangeController.mm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Details/ASRangeController.mm b/Source/Details/ASRangeController.mm index 5bc4cfb191..e5ae2345f4 100644 --- a/Source/Details/ASRangeController.mm +++ b/Source/Details/ASRangeController.mm @@ -410,9 +410,16 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive; #pragma mark - Notification observers +/** + * If we're in a restricted range mode, but we're going to change to a full range mode soon, + * go ahead and schedule the transition as soon as all the currently-scheduled rendering is done #1163. + */ - (void)registerForNodeDisplayNotificationsForInterfaceStateIfNeeded:(ASInterfaceState)interfaceState { - if (!_didRegisterForNodeDisplayNotifications) { + // Do not schedule to listen if we're already in full range mode. + // This avoids updating the range controller during a collection teardown when it is removed + // from the hierarchy and its data source is cleared, causing UIKit to call -reloadData. + if (!_didRegisterForNodeDisplayNotifications && _currentRangeMode != ASLayoutRangeModeFull) { ASLayoutRangeMode nextRangeMode = [ASRangeController rangeModeForInterfaceState:interfaceState currentRangeMode:_currentRangeMode]; if (_currentRangeMode != nextRangeMode) {