From b02366c009f3224608a6de8c05d25911e69acbfb Mon Sep 17 00:00:00 2001 From: delcamf Date: Fri, 2 Oct 2026 17:06:12 -0500 Subject: [PATCH] iOS: remove every surplus page spacer layer, not every other one layoutPageSpacers trims the overlay to the spacer count by iterating sublayers while removing from it. The getter hands out the live array, so each removal shifts the rest down and the loop skips every other layer. A page that sends fewer spacers keeps stale strips. Iterating a copy removes them all. Checked with a standalone program over CALayer: 182 layers trimmed to 4 leave 93 with the live array and 4 with a copy. Not built into the app. Co-Authored-By: Claude Fable 5.1 --- apple/RNCWebViewImpl.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apple/RNCWebViewImpl.m b/apple/RNCWebViewImpl.m index 7056a39ce..156f127d9 100644 --- a/apple/RNCWebViewImpl.m +++ b/apple/RNCWebViewImpl.m @@ -1030,7 +1030,8 @@ - (void)layoutPageSpacers [scrollView bringSubviewToFront:_pageSpacersOverlay]; CGFloat width = MAX(scrollView.contentSize.width, scrollView.bounds.size.width); CGFloat maxBottom = 0; - NSArray *spacerLayers = _pageSpacersOverlay.layer.sublayers ?: @[]; + // a copy: sublayers shrinks as the surplus layers below are removed + NSArray *spacerLayers = [_pageSpacersOverlay.layer.sublayers copy] ?: @[]; [CATransaction begin]; [CATransaction setDisableActions:YES]; for (NSUInteger i = 0; i < _pageSpacers.count; i++) {