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 tab switcher crashes (speculative fix) #3319

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions DuckDuckGo/TabSwitcherViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,12 @@ extension TabSwitcherViewController: TabObserver {
return
}

if let index = tabsModel.indexOf(tab: tab), index < collectionView.numberOfItems(inSection: 0) {
collectionView.reconfigureItems(at: [IndexPath(row: index, section: 0)])
}
collectionView.performBatchUpdates({}, completion: { [weak self] completed in
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, so in this case we aren't actually making any batch changes, but rather just waiting for the completion? Not sure I totally follow it, but functionally it works great for me locally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah my thinking is if we're trying to reconfigure while some other batch is in progress then it's safer to wait. tbh it's just a guess so we'll see how it goes for a week before it gets released. Thanks.

guard completed, let self = self else { return }
if let index = self.tabsModel.indexOf(tab: tab), index < self.collectionView.numberOfItems(inSection: 0) {
self.collectionView.reconfigureItems(at: [IndexPath(row: index, section: 0)])
}
})
}
}

Expand Down
Loading