Skip to content

Commit dbe1ceb

Browse files
authored
Follow up on the ASRangeController fix in #1418 (#1419)
The changes in #1418 is a bit too aggressive when it comes to nodes that are in display range. It forces those nodes to not preload. Also update the changes to avoid diluting the experiment data by triggering too broadly (i.e avoid triggering when the old and new implementations yield the same result leading to no behavior change).
1 parent 5937ac3 commit dbe1ceb

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

Source/Details/ASRangeController.mm

+20-11
Original file line numberDiff line numberDiff line change
@@ -351,25 +351,34 @@ - (void)_updateVisibleNodeIndexPaths
351351
} else {
352352
// If selfInterfaceState isn't visible, then visibleIndexPaths represents either what /will/ be immediately visible at the
353353
// instant we come onscreen, or what /will/ no longer be visible at the instant we come offscreen.
354-
// So, preload and display all of those things, but don't waste resources preloading others.
355-
// We handle this as a separate case to minimize set operations, including -containsObject:.
354+
// So, preload and display all of those things, but don't waste resources displaying others.
356355
//
357356
// DO NOT set Visible: even though these elements are in the visible range / "viewport",
358357
// our overall container object is itself not yet, or no longer, visible.
359358
// The moment it becomes visible, we will run the condition above.
360359

361-
BOOL shouldUpdateInterfaceState = NO;
362-
if (ASActivateExperimentalFeature(ASExperimentalFixRangeController)) {
363-
shouldUpdateInterfaceState = [visibleIndexPaths containsObject:indexPath];
364-
} else {
365-
shouldUpdateInterfaceState = [allCurrentIndexPaths containsObject:indexPath];
360+
ASInterfaceState interfaceStateBeforeFix = interfaceState;
361+
if ([allCurrentIndexPaths containsObject:indexPath]) {
362+
interfaceStateBeforeFix |= ASInterfaceStatePreload;
363+
if (rangeMode != ASLayoutRangeModeLowMemory) {
364+
interfaceStateBeforeFix |= ASInterfaceStateDisplay;
365+
}
366366
}
367-
368-
if (shouldUpdateInterfaceState) {
369-
interfaceState |= ASInterfaceStatePreload;
367+
368+
ASInterfaceState interfaceStateAfterFix = interfaceState;
369+
if ([visibleIndexPaths containsObject:indexPath]) {
370+
interfaceStateAfterFix |= ASInterfaceStatePreload;
370371
if (rangeMode != ASLayoutRangeModeLowMemory) {
371-
interfaceState |= ASInterfaceStateDisplay;
372+
interfaceStateAfterFix |= ASInterfaceStateDisplay;
372373
}
374+
} else if ([displayIndexPaths containsObject:indexPath]) {
375+
interfaceStateAfterFix |= ASInterfaceStatePreload;
376+
}
377+
378+
if (interfaceStateBeforeFix != interfaceStateAfterFix && ASActivateExperimentalFeature(ASExperimentalFixRangeController)) {
379+
interfaceState = interfaceStateAfterFix;
380+
} else {
381+
interfaceState = interfaceStateBeforeFix;
373382
}
374383
}
375384

0 commit comments

Comments
 (0)