-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Random offlineRegionStatusDidChange unrecognized selector crash #4394
Comments
Looks like OfflineRegionObserver has a dangling pointer to the MGLOfflinePack. The workaround seems to be to hold a strong reference to the offline pack somewhere. For example, if you have a table of offline packs in your UI, the table view controller should manage an array of offline packs, only removing them just before calling -removePackWithCompletionHandler:. See https://github.com/mapbox/mapbox-gl-native/blob/ios-v3.2.0-beta.2/platform/ios/app/MBXOfflinePacksTableViewController.m for the full example code. |
This is exactly the kind of scenario I'm trying to avoid in #4287. |
@1ec5 This happens on first access of |
|
@1ec5 I took another look and in fact getPacksWithCompletionHandler was being called in response to app activation. The docs need to be updated to clearly that offline packs passed to the completion handler need to be retained by the calling context. Ultimately, it would be preferrable to have a different API on MGLOfflineStorage and MGLOfflinePack. Having to fetch all packs to fetch a specific pack is inefficient. The delegate protocol that is supposed to be used by both MGLOfflineStorage and app code is too fragile. |
Updated. Thanks for the reminder.
Good point. The iOS offline API started out mimicking NSURLSession and related classes to some extent, but it no longer clearly fits into that paradigm. MGLOfflinePack is just a lightweight wrapper around The new notification-based design in #4287 (comment) will likely have MGLOfflineStorage maintain a master list of MGLOfflinePacks that allows synchronous access (adding, pausing, and resuming would still be asynchronous). I think we’ll also be able to maintain a one-to-one relationship between MGLOfflinePacks and |
@1ec5 Still crashing even though calling context now retains all offline packs from |
After an offline pack successfully completes downloading the app randomly crashes on subsequent launches:
-[__NSTaggedDate offlineRegionStatusDidChange:]: unrecognized selector sent to instance 0xe00007fae0873c04
The text was updated successfully, but these errors were encountered: