iOS 16: Unexpected behavior with UISearchController and UITableView scrolling performance
I've been banging my head against this for hours. I'm encountering a performance issue when implementing a `UISearchController` in conjunction with a `UITableView` on iOS 16. The problem arises when I start typing in the search field; the scrolling of the `UITableView` becomes noticeably sluggish. Despite having cached the data and utilizing `UITableViewDiffableDataSource`, the UI freezes for a brief moment, and I see a temporary stutter. I've already tried to optimize the cell configuration and ensure my data source is efficiently updated, but I still experience this delay. Here's a simplified snippet of my implementation: ```swift class MyViewController: UIViewController, UITableViewDelegate, UISearchResultsUpdating { var tableView: UITableView! var searchController: UISearchController! var dataSource: UITableViewDiffableDataSource<Section, Item>! override func viewDidLoad() { super.viewDidLoad() setupTableView() setupSearchController() } private func setupTableView() { tableView = UITableView(frame: view.bounds) tableView.delegate = self view.addSubview(tableView) configureDataSource() } private func setupSearchController() { searchController = UISearchController(searchResultsController: nil) searchController.searchResultsUpdater = self searchController.obscuresBackgroundDuringPresentation = false searchController.searchBar.placeholder = "Search Items" navigationItem.searchController = searchController } func updateSearchResults(for searchController: UISearchController) { guard let searchText = searchController.searchBar.text, !searchText.isEmpty else { return } let filteredItems = items.filter { $0.name.contains(searchText) } // Update data source here var snapshot = NSDiffableDataSourceSnapshot<Section, Item>() snapshot.appendSections([.main]) snapshot.appendItems(filteredItems) dataSource.apply(snapshot, animatingDifferences: true) } } ``` I've verified that my table view cells are lightweight and I'm not performing heavy computations in the `cellForRowAt`. Could this performance issue be related to how the search results are applied to the data source, or is it more likely an issue with the way the `UISearchController` handles events? Any insights or suggestions for performance improvements would be greatly appreciated.