Skip to content

fix(TextureIGListKitExtensions): guard viewForSupplementaryElementOfKind against stale section indices#13

Merged
3a4oT merged 1 commit into
developmentfrom
fix-stale-supplementary-section-guard
May 13, 2026
Merged

fix(TextureIGListKitExtensions): guard viewForSupplementaryElementOfKind against stale section indices#13
3a4oT merged 1 commit into
developmentfrom
fix-stale-supplementary-section-guard

Conversation

@3a4oT

@3a4oT 3a4oT commented May 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • After performUpdates reduces the section count, UICollectionView may still hold cached layout attributes for removed sections and request supplementary views for them in a subsequent layout pass
  • Without a guard, the bridge forwards to IGListAdapter which throws NSInternalInconsistencyException because sectionController at that index is nil
  • Added sectionController(forSection:) nil-check before forwarding in the viewForSupplementaryElementOfKind:atIndexPath: Interop forwarder — returns a zero-size UICollectionReusableView placeholder when the section is stale
  • Added regression test that calls the bridge selector directly with an out-of-range section (simulating the stale layout attributes case) — confirmed the test crashes the process without the fix and passes with it

…ind against stale section indices

After performUpdates reduces the section count, UICollectionView may still hold
cached layout attributes for removed sections and request supplementary views for
them during the next layout pass. Without a guard, the bridge forwards to
IGListAdapter which throws NSInternalInconsistencyException because the section
controller at that index is nil.

Add a sectionController(forSection:) nil-check before forwarding to IGListAdapter
in the viewForSupplementaryElementOfKind:atIndexPath: Interop forwarder. When the
section is out of range, return a zero-size UICollectionReusableView placeholder
that satisfies UIKit without crashing.

Add a regression test that calls the bridge selector directly with a section index
that was removed by a preceding performUpdates — verifying the placeholder path
is taken instead of crashing.
@3a4oT 3a4oT merged commit c92fcf4 into development May 13, 2026
27 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant