Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix empty indexPath crash shouldInvalidateLayout #88

Merged
merged 1 commit into from
Sep 29, 2020

Conversation

SNagappan
Copy link
Contributor

Details

shouldInvalidateLayout crashes if IndexPath is empty

Related Issue

#77

Types of changes

  • Docs change / refactoring / dependency upgrade
  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@bryankeller bryankeller self-requested a review September 29, 2020 02:43
@bryankeller bryankeller added the bug Something isn't working label Sep 29, 2020
@bryankeller
Copy link
Contributor

Hi @SNagappan - thanks for finding this bug and making a fix. Before I approve, I just want to understand a bit more about how this crash is possible. Do you have a repro case? I'm trying to figure out why shouldInvalidateLayout is getting called with an empty index path in the first place.

@bryankeller
Copy link
Contributor

Ah, I see you emailed me some additional context. Thanks for that! So weird that this is happening. Looks like it might be related to voiceover / UIAccessibility, which would explain why it's so rare in your project.

Crashed: com.apple.main-thread
0  libswiftUIKit.dylib            0x1c285a0c8 IndexPath.section.getter + 168
1  MagazineLayout                 0x1037be1e8 itemModelHeightModeDuringPreferredAttributesCheck #1 (at:sectionModels:) in ModelState.itemModelHeightModeDuringPreferredAttributesCheck(at:) + 118 (ModelState.swift:118)
2  MagazineLayout                 0x1037afe38 MagazineLayout.shouldInvalidateLayout(forPreferredLayoutAttributes:withOriginalAttributes:) + 132 (ModelState.swift:132)
3  MagazineLayout                 0x1037b020c @objc MagazineLayout.shouldInvalidateLayout(forPreferredLayoutAttributes:withOriginalAttributes:) + 4379738636 (<compiler-generated>:4379738636)
4  UIKitCore                      0x1b1c352a8 -[UICollectionView _checkForPreferredAttributesInView:originalAttributes:] + 656
5  UIKitCore                      0x1b1c36838 -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:] + 880
6  UIKitCore                      0x1b1c5c0f4 -[UICollectionView preferredFocusedView] + 2404
7  UIKit                          0x1f578b9fc -[UICollectionViewAccessibility preferredFocusedView] + 56
8  UIKitCore                      0x1b1f3bd28 __UIFocusEnvironmentPreferredFocusedView + 64
9  UIKitCore                      0x1b29929e0 -[UIView preferredFocusEnvironments] + 48
10 UIKit                          0x1f5815858 -[UIViewAccessibility preferredFocusEnvironments] + 68
11 UIKitCore                      0x1b1f3bdb0 _UIFocusEnvironmentEffectivePreferredFocusEnvironments + 72
12 UIKitCore                      0x1b1f4cce4 -[_UIFocusEnvironmentPreferenceEnumerationContext _resolvePreferredFocusEnvironments] + 224
13 UIKitCore                      0x1b1f4cbc4 -[_UIFocusEnvironmentPreferenceEnumerationContext prefersNothingFocused] + 40
14 UIKitCore                      0x1b1f4d8ec _enumeratePreferredFocusEnvironments + 184
15 UIKitCore                      0x1b1f4d74c -[_UIFocusEnvironmentPreferenceEnumerator enumeratePreferencesForEnvironment:usingBlock:] + 200
16 UIKitCore                      0x1b1f4dfe8 -[_UIDeepestPreferredEnvironmentSearch deepestPreferredFocusableItemForEnvironment:withRequest:] + 592
17 UIKitCore                      0x1b1f92484 -[UIFocusUpdateContext _updateDestinationItemIfNeeded] + 232
18 UIKitCore                      0x1b1f9227c -[UIFocusUpdateContext _destinationItemInfo] + 28
19 UIKitCore                      0x1b1f92158 -[UIFocusUpdateContext nextFocusedItem] + 24
20 UIKitCore                      0x1b1f81bf8 -[UIFocusSystem updateFocusIfNeeded] + 192
21 UIKitCore                      0x1b1c3d0cc __43-[UICollectionView _updateVisibleCellsNow:]_block_invoke.1183 + 184
22 UIKitCore                      0x1b29a4d0c +[UIView(Animation) performWithoutAnimation:] + 96
23 UIKitCore                      0x1b1c3b6f0 -[UICollectionView _updateVisibleCellsNow:] + 9220
24 UIKitCore                      0x1b1c3ed38 -[UICollectionView layoutSubviews] + 320
25 UIKitCore                      0x1b29b1954 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2464
26 QuartzCore                     0x1b2eb19e8 -[CALayer layoutSublayers] + 288
27 QuartzCore                     0x1b2eb7eb4 CA::Layer::layout_if_needed(CA::Transaction*) + 520
28 QuartzCore                     0x1b2ec31d0 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 140
29 QuartzCore                     0x1b2e0f500 CA::Context::commit_transaction(CA::Transaction*, double, double*) + 416
30 QuartzCore                     0x1b2e39698 CA::Transaction::commit() + 728
31 QuartzCore                     0x1b2e3a948 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92
32 CoreFoundation                 0x1afbebecc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
33 CoreFoundation                 0x1afbe65b0 __CFRunLoopDoObservers + 604
34 CoreFoundation                 0x1afbe6af8 __CFRunLoopRun + 960
35 CoreFoundation                 0x1afbe6200 CFRunLoopRunSpecific + 572
36 GraphicsServices               0x1c5ce1598 GSEventRunModal + 160
37 UIKitCore                      0x1b24ac004 -[UIApplication _run] + 1052
38 UIKitCore                      0x1b24b15d8 UIApplicationMain + 164

Copy link
Contributor

@bryankeller bryankeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the details over email and for putting up a fix!

@bryankeller bryankeller merged commit 151d34a into airbnb:master Sep 29, 2020
@bryankeller bryankeller mentioned this pull request Sep 29, 2020
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants