-
Notifications
You must be signed in to change notification settings - Fork 1.3k
MGLMapSnapshotter iOS issue specific to Mapbox version 4.1+ #12336
Comments
Thanks for the report @JustinGanzer. Can you confirm that the crashes you see are on devices as opposed to simulators? As for the less-than-useful callstack - we're tracking this issue over at #8463 (comment). /cc @ChrisLoer |
The probably-relevant change between 4.0 and 4.1 is this PR: #11831. Without really digging into the details of your example (or my rusty ARC knowledge), I suspect some of the "self capturing" we were previously doing extended the lifetime of the MGLMapSnapshotter long enough for your first example to work, but now the MGLMapSnapshotter is reaching the end of its life before the callback gets called, and its teardown aborts the callback. In your second example, you have:
I haven't identified a specific problem, but is there a reason you need the extra complexity of going through the main dispatch queue? You could create the snapshotter on the dispatch queue, start it from that queue, and use the |
@JustinGanzer a couple of questions:
|
First of all, thanks for the reply! New to Github, and appreciate the time you have taken for my issue.
Yes. These crashes take place on users with iPhones, running versions of iOS 11 and up. Almost every user goes through this bit of code multiple times within their session and they have not produced crashes until the update to Mapbox 4.1. I am unable to reproduce this crash in my own development environment, either on devices or simulators, as the crash affects only about 1-2% of all sessions.
I am sorry about the mistake. What you saw was a leftover from a piece of code I was experimenting with. I have removed the piece in the edited issue description.
I am too using DispatchQueue.global().async { ... }. Could you let me know which code block of my issue you were using, the first or second that is?
Note that the following answer is only certain for simulators, as I will try with actual devices again soon, but I am almost certain the same problem was the case for devices: Well yes. Running said code (exclusively to ensure there are no threading issues) and not dispatching the MGLSnapshotter's I have uploaded the crashlog in a textfile to reduce clutter: @julianrex @ChrisLoer
Hope I could clarify things a bit. |
Thanks for the great follow-up @JustinGanzer - I was able to create a test scenario that exhibits the behaviour you're seeing so that gives us a place to start. Hopefully we'll have an update soon. |
@JustinGanzer in your first code snippet the snapshotter is being deallocated before the snapshot completes (as @ChrisLoer states above), and the completion block isn't being called. My comment above:
is incorrect - apologies, I misread what you had written (and missed your typo comment) However, you do need to ensure that mapbox-gl-native/platform/ios/Integration Tests/Snapshotter Tests/MGLMapSnapshotterSwiftTests.swift Lines 36 to 53 in 5e3478e
Without seeing the rest of the surrounding code in your second snippet, it's difficult to tell why that's working - though the assumption is that the snapshotter is being captured and is alive for the duration). (In Objective-C it's a little more complicated: you'd need to make snapshotter a |
@julianrex My code now looks like this and works flawlessly:
Is this (manually capturing the snapshotter inside the callback) the intended behaviour of the
The answer probably is the What i still fail to understand is why the snippet below will crash almost immediately. I feel like I am stretching the intentions of this github issue, but perhaps this might actually be a scenario where the snapshotter is released too early?
|
Any progress on this issue? It seems you can no longer run Snapshotter in a background queue (e.g. global or global .userInitiated). There is a check for this in a code which was not there in iOS SDK v3.x... For some reason it now requires a queue that can do user interaction, I guess... It would be better if background running still is possible! |
I already deployed 4.5.0 alpha and problem is indeed fixed there! Thank you! |
Hello all,
I've recently come across an issue with the MGLMapSnapshotter in iOS.
What I intend to do with it is create a snapshot and nothing more.
In version 4.0 the following worked as I've expected:
With an update to Mapbox 4.1 the above code does not work anymore. Instead the snappshotter.start callback is never called, even after multiple minutes of runtime.
I've got it working again by rewriting above code to the following:
(All I have done is moving the initialisation of the MapSnapShotter out of the Dispatch.main.async block)
Could someone explain as to why that is? Is this a bug?
However this results in a new problem that wasn't appearing in Mapbox 4.0 and that is
that now my app produces crashes. Not too often, but still.
Since Mapbox 4.1 with the included code change seen above, I have multiple crashlogs of other users that looks as follows:
Steps to reproduce
Expected behavior
Both code snippets should run on both Mapbox versions and produce no crashes.
Actual behavior
First code snipped does no longer run on Mapbox 4.1. Second code snipped produces crashes.
Configuration
Mapbox SDK versions:
Mapbox 4.1.1
iOS/macOS versions:
iOS 11.3 through 11.4
Device/simulator models:
All iphone models beyond iPhone 5s
Xcode version:
9.4.1
Edited on 07.07.2018 14:13 London Time ->
Removed snapshotter = nil
from code. Typo left from testing.The text was updated successfully, but these errors were encountered: