Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Unrecognized selector crash when suspending and removing MGLOfflinePack #6092

Closed
Jackhammer42 opened this issue Aug 19, 2016 · 10 comments · Fixed by #11821
Closed

Unrecognized selector crash when suspending and removing MGLOfflinePack #6092

Jackhammer42 opened this issue Aug 19, 2016 · 10 comments · Fixed by #11821
Labels
crash iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS offline

Comments

@Jackhammer42
Copy link

Platform: iOS 9.3.4
Mapbox SDK version: 3.3.1

Steps to trigger behavior

When I try to cancel the download of an MGLOfflinePack, i get this error:

-[NSTaggedPointerString offlineRegionStatusDidChange:]: unrecognized selector sent to instance 0xa0000000148344a4
2016-08-19 16:53:08.187 ChemPark[659:57661] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString offlineRegionStatusDidChange:]: unrecognized selector sent to instance 0xa0000000148344a4'
*** First throw call stack:
(0x181aa6db0 0x18110bf80 0x181aadc4c 0x181aaabec 0x1819a8c5c 0x100f484e4 0x102ba9a7c 0x102ba9a3c 0x102baf4e4 0x181a5cd50 0x181a5abb8 0x181984c50 0x18326c088 0x186c6e088 0x1002b1c70 0x1815228b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

I am using this code for the task:

let packs = MGLOfflineStorage.sharedOfflineStorage().packs

        for pack in packs! {

            pack.suspend()

            MGLOfflineStorage.sharedOfflineStorage().removePack(pack, withCompletionHandler: nil)

        }

It seems similar to #4394, except this issue only seems to happen if i cancel the download, not after successfully completing the download.

Expected behavior

I was hoping to stop the download.

Actual behavior

Crash

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS crash offline labels Aug 19, 2016
@1ec5
Copy link
Contributor

1ec5 commented Aug 19, 2016

Related to #5538.

@1ec5
Copy link
Contributor

1ec5 commented Aug 19, 2016

Does the crash occur if you only remove the pack instead of canceling it? Removing the pack should cancel it automatically, if asynchronously.

@Jackhammer42
Copy link
Author

I tried

let packs = MGLOfflineStorage.sharedOfflineStorage().packs

        for pack in packs! {


            MGLOfflineStorage.sharedOfflineStorage().removePack(pack, withCompletionHandler: nil)

        }

Same crash, after a few starting and canceling cycles.

When I trie

let packs = MGLOfflineStorage.sharedOfflineStorage().packs

        for pack in packs! {


            let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
            dispatch_async(dispatch_get_global_queue(priority, 0)) {

                MGLOfflineStorage.sharedOfflineStorage().removePack(pack, withCompletionHandler: nil)
                dispatch_async(dispatch_get_main_queue()) {

                }
            }




         }

It seems to work for a little more starting a canceling cycles, but it crashes in the end as well.

@marceln
Copy link

marceln commented Mar 28, 2017

This isn't fixed in any of the latest versions, right?

@1ec5
Copy link
Contributor

1ec5 commented Mar 29, 2017

#6186 should’ve made this crash less likely to occur; as a stale pointer issue, it’s difficult to say for sure that the crash is fixed.

@Jackhammer42
Copy link
Author

I will try to produce the error with the latest version and give you feedback about the result.

@Jackhammer42
Copy link
Author

sorry, still seeing this error :( (v. 3.5.0)

@boundsj boundsj added this to the ios-v3.6.0 milestone Apr 5, 2017
@1ec5
Copy link
Contributor

1ec5 commented Apr 5, 2017

MGLOfflinePack would really benefit from the sort of std::any usage being introduced to MGLStyleLayer and MGLSource in #8626 for #7375.

/cc @boundsj @jfirebaugh

@1ec5 1ec5 modified the milestones: ios-v3.7.0, ios-v3.6.0 Jun 22, 2017
@lilykaiser lilykaiser removed this from the ios-v3.7.0 milestone Sep 18, 2017
@georgejlee
Copy link

I have seen this crash as well. I am on Mapbox-iOS-SDK-3.6.4. I've attached a stack trace. The line that crashes is [pack offlineRegionStatusDidChange:status];:

void MBGLOfflineRegionObserver::statusChanged(mbgl::OfflineRegionStatus status) {
    dispatch_async(dispatch_get_main_queue(), ^{
        [pack offlineRegionStatusDidChange:status];
    });
}

I have tried suspending the offline pack before removing as well as removing the offline pack without suspending, crashes occur in both cases. Can you help? This is one of the most frequent crashes in our app now.

Unknown.txt

@georgejlee
Copy link

This is still happening for me on 3.7.0. Any updates on this? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS offline
Projects
None yet
6 participants