Open cnordvik opened 6 years ago
Hey,
Curious case. You don't activate infinite scroll for WKWebView
right? Looking at the log it seems that something got over-released but I may be wrong.
If infinite scroll is not enabled for the WKWebView
then pb_setContentOffset
should only call super implementation. Looking at your trace the -[UIScrollView setContentOffset:]
is actually being called so the crash happens somewhere down the road?
Do you know how to reproduce this crash?
That's the sad part, I've never seen the crash myself. We have a twitter timeline that is implemented by using UICollectionViewController.
I included some parts of the code. Can it be related to the fact that we may sometimes not call finishInfiniteScroll after addInfiniteScroll if something goes wrong in the network call?
public func loadTweets() {
refreshControl.addTarget(self, action: #selector(reload), for: .valueChanged)
collectionView?.addSubview(refreshControl)
collectionView?.addInfiniteScroll(handler: { [weak self] scrollView in
self?.refresh(load: .previous)
})
refresh(load: .reload)
}
private func refresh(load: LoadType) {
let sinceId: String?
Logging.debug("Refreshing twitter feed! \(load)")
switch load {
case .previous:
sinceId = loadedTweets.last?.tweetID
default:
sinceId = nil
}
matchDataSource.loadPreviousTweets(beforePosition: sinceId) { [weak self] tweets, cursor, error in
guard let `self` = self else { return }
switch ((tweets, cursor), error) {
case ((let tweets?, _), _):
self.updateTweets(tweets: tweets, load: load)
case ((_, _), let error?):
Logging.debug(error.localizedDescription)
self.refreshControl.endRefreshing()
self.collectionView?.finishInfiniteScroll()
default:
break
}
}
}
.finishInfiniteScroll
only runs some animations and .addInfiniteScroll
should only initialize once, all subsequent calls only update the handler block. So shouldn't matter in your case.
Is it possible that underlying UIScrollView
somehow outlives WKWebView
? Maybe you drop a reference to WKWebView
somewhere too early or something?
I saw some errors related to _notifyDidScroll
before and most of them were related to bad timing in UIKit.
I can only guess at this point, the last call in stack trace is related to WKScrollViewDelegateForwarder
, I don't think UIScrollView+InfiniteScroll
causes the crash per se.
The crash log you shared points to WKWebView
, so I don't think it's related to UICollectionView
that you use. It could be that you display the WKWebView
inside of cell that's being reused, so maybe you need to clean up WKWebView
when cell goes out of view or being reused..
Have the same issue
http://crashes.to/s/2290ec3917a
Any idea why these crashes occur? We have 6000 crashes of these so would be nice to get to the root reason of it but I cannot see anything wrong in the code.