Post

Replies

Boosts

Views

Activity

Crash in UICollectionViewCompositionalLayout iOS 13 with decoration views
I have two section backgrounds for my compositional layout. layout.register(     FollowingSectionBackgroundView.self,     forDecorationViewOfKind: FollowingCollectionViewController.sectionBackgroundDecorationFollowing) layout.register(     BrowseSectionBackgroundView.self,     forDecorationViewOfKind: FollowingCollectionViewController.sectionBackgroundDecorationBrowse) And I configure them like so in my UICollectionViewCompositonaLayoutClosure         if sectionIndex == 0 {             let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background(                 elementKind: FollowingCollectionViewController.sectionBackgroundDecorationFollowing)             section.decorationItems = [sectionBackgroundDecoration]         } else {             let sectionBackgroundDecoration = NSCollectionLayoutDecorationItem.background(                 elementKind: FollowingCollectionViewController.sectionBackgroundDecorationBrowse)             section.decorationItems = [sectionBackgroundDecoration]         } And this seems to be working just fine, however I have seen crashes uploaded that say: Fatal Exception: NSInternalInconsistencyException no UICollectionViewLayoutAttributes instance for -layoutAttributesForDecorationViewOfKind: section-background-browse at path &lt;NSIndexPath: 0xfe6f76a7b11ddfee&gt; {length = 2, path = 0 - 0} The crash appears to happen when the user searches.         isSearching = true         let following = FollowingController.filterBrowse(with: filter).sorted { $0.name < $1.name }         var snapshot = NSDiffableDataSourceSnapshot&lt;SectionLayoutKind, FollowingEntity&gt;()         snapshot.appendSections([.browse])         snapshot.appendItems(following)         dataSource.apply(snapshot, animatingDifferences: true) Im unable to reproduce this issue but just curious if anyone has run into this, and might have an idea for solving it.
1
0
1.1k
Jul ’20
UICollectionViewDiffableDataSource crash
Why does returning nil from UICollectionViewDiffableDataSource&lt;FeedElement, Entity&gt;(collectionView: collectionView) {             (collectionView: UICollectionView, indexPath: IndexPath, entity: Entity) -> UICollectionViewCell? in result n "the collection view's data source did not return a valid cell from" Isn't the UICollectionViewCell optional?
5
0
2.3k
Jul ’20
UICollectionViewDataSourcePrefetching & UICollectionViewDiffableDataSource
I can't seem to get UICollectionViewDataSourcePrefetching working with DiffableDatasource, my delegate methods are not being called. Do these work together? &#9;&#9;func viewDidLoad() &#9;&#9;&#9;&#9;....         collectionView.prefetchDataSource = self         collectionView.isPrefetchingEnabled = true &#9;&#9;} extension ViewController: UICollectionViewDataSourcePrefetching {     func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {         let urls: [URL] = indexPaths.compactMap { indexPath in             guard let displayableItem = dataSource.itemIdentifier(for: indexPath),                 let itemViewModel = displayableItem.item as? ViewModel,                 let image = itemViewModel.firstImageURL else {                     return nil             }             return image         }         ATHLogging.log.critical("prefetching: \(urls)")         preheater.startPreheating(with: urls)     }
2
0
2.3k
Aug ’20
Crash in UICollectionViewDiffableDataSource - SupplementaryView
I have a crash happening when applying a snapshot. 9/10 times its seems to work. When we re-fetch backend data, and apply the snapshot sometimes we get the follow crash the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath (cover-edge-trailing-element-kind,<NSIndexPath: 0xf45fd089cda10b3f> {length = 2, path = 55 - 1}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil ((null)) We don't call this function, as it seems to be done by the diffable datasource. Fatal Exception: NSInternalInconsistencyException 0&#9;CoreFoundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x1b75c2300 __exceptionPreprocess 1&#9;libobjc.A.dylib&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1b72d6c1c objc_exception_throw 2&#9;CoreFoundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x1b74bf1f8 +[_CFXNotificationTokenRegistration keyCallbacks] 3&#9;Foundation&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9; 0x1b7903998 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] 4&#9;UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf133dc -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:] 5&#9;UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf2dc6c -[UICollectionView _viewAnimationsForCurrentUpdate] 6&#9;UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf31d68 __71-[UICollectionView _updateWithItems:tentativelyForReordering:animator:]_block_invoke.2004 7&#9;UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1bbbcf5d8 +[UIView(Animation) performWithoutAnimation:] 8&#9;UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf30f2c -[UICollectionView _updateWithItems:tentativelyForReordering:animator:] 9&#9;UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf2b488 -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] 10 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf32f4c -[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:] 11 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf332d0 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] 12 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf33100 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] 13 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf3307c -[UICollectionView _performBatchUpdates:completion:invalidationContext:] 14 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf32fa8 -[UICollectionView performBatchUpdates:completion:] 15 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baf41268 -[UICollectionView _performDiffableUpdate:] 16 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baee7e6c -[_UIDiffableDataSourceViewUpdater _performUpdateWithCollectionViewUpdateItems:dataSourceSnapshotter:updateHandler:completion:] 17 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baee10f4 -[__UIDiffableDataSource _commitNewDataSource:withViewUpdates:completion:] 18 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baedc0c0 66-[UIDiffableDataSource applyDifferencesFromSnapshot:completion:]_block_invoke.154 19 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baedc388 66-[UIDiffableDataSource applyDifferencesFromSnapshot:completion:]_block_invoke.183 20 libdispatch.dylib&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1b726233c _dispatch_client_callout 21 libdispatch.dylib&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1b726f1f4 _dispatch_lane_barrier_sync_invoke_and_complete 22 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baedbba8 -[__UIDiffableDataSource applyDifferencesFromSnapshot:completion:] 23 UIKitCore&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x1baedcc68 -[__UIDiffableDataSource applyDifferencesFromSnapshot:animatingDifferences:completion:] 24 libswiftUIKit.dylib&#9;&#9;&#9;&#9;&#9;&#9;0x1edef8030 UICollectionViewDiffableDataSource.apply(_:animatingDifferences:completion:) 25 theathletic-ios&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x105048b60 closure #1 in RealTimeContentsViewController.fetchData(with:newWatcher:) + 137 (RealTimeContentsViewController.swift:137) 26 theathletic-ios&#9;&#9;&#9;&#9;&#9;&#9;&#9;&#9;0x10504b48c RealTimeContentsViewController.updateDataSource(for:completion:) + 265 (RealTimeContentsViewController.swift:265) 27 theathletic-ios&#9; Heres how we are registering, creating, and supplying the view static let coverEdgeTrailingIdentifier = "cover-edge-trailing-element-kind"         collectionView.register(             CoverEdgeCollectionReusableView.self,             forSupplementaryViewOfKind: K.coverEdgeTrailingIdentifier,             withReuseIdentifier: CoverEdgeCollectionReusableView.reuseIdentifier) dataSource.supplementaryViewProvider = { (             collectionView: UICollectionView,             kind: String,             indexPath: IndexPath) -> UICollectionReusableView? { return collectionView.dequeueReusableSupplementaryView(             ofKind: kind,             withReuseIdentifier: CoverEdgeCollectionReusableView.reuseIdentifier,             for: indexPath) as! CoverEdgeCollectionReusableView }
0
0
1.4k
Sep ’20
Widget not taking over full height
There is a black bar at the top of my Widget and I can't seem to figure out how to get rid of it. struct A1EntryView : View {     var entry: Provider.Entry     var body: some View {         Text("Temp")             .frame(maxHeight: .infinity)             .background(Color(.red))             .ignoresSafeArea(.all)     } }
0
0
556
Sep ’20