This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Repository navigation
Keep MGLMapSnapshotter alive through completion - #211
Merged
Merged
Conversation
This was referenced Mar 14, 2020
1ec5
commented
Mar 14, 2020
Contributor
Author
There was a problem hiding this comment.
Probably should link to this PR instead of #210.
1ec5
commented
Mar 14, 2020
Contributor
Author
There was a problem hiding this comment.
This comment is inaccurate: it crept back in when I reverted #210’s changes to the test, but we want the completion handler to be called with a valid snapshot now.
1ec5
force-pushed
the
1ec5-snapshotter-keep-alive-12336
branch
from
March 16, 2020 18:31
272fdfe to
944388e
Compare
julianrex
reviewed
Mar 16, 2020
1ec5
force-pushed
the
1ec5-snapshotter-parallel-state-209
branch
from
March 17, 2020 01:15
055a482 to
d357f8c
Compare
1ec5
force-pushed
the
1ec5-snapshotter-keep-alive-12336
branch
from
March 17, 2020 01:17
54f4f6d to
363610c
Compare
1ec5
changed the base branch from
1ec5-snapshotter-parallel-state-209
to
master
March 17, 2020 02:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Strongly capture MGLMapSnapshotter until its completion handler finishes executing. The developer no longer needs to explicitly capture the snapshotter in the completion handler to prevent it from being canceled or deallocated, because the internal completion handler does so for the developer.
Before #210, a snapshotter that wasn’t captured in its completion handler would be deallocated as soon as it went out of scope, but the completion handler would be called with an error “headlessly” after the snapshotter got deallocated. As of #210, the same snapshotter would’ve silently gone away without calling the completion handler, since it was considered the responsibility of the developer to hang onto the snapshotter. As of this PR, the developer is no longer required to hang onto the snapshotter, and the completion handler will generally receive a snapshot rather than an error.
This new behavior matches MapKit’s MKMapSnapshotter and is ideal for one-off usage. I had shied away from it in #200 (comment) because of the complexity around keeping the completion handler alive, but #210 gives us more confidence about the control flow and lifetime of any captured state. Nonetheless, this PR needs extra scrutiny because it possibly reintroduces edge cases that #210 had eliminated by reducing the snapshotter’s scope. In particular, we should make sure the application can reliably terminate while snapshotters are active without crashing.
Depends on #210. Fixes mapbox/mapbox-gl-native#12336 in a different way.
/cc @mapbox/maps-ios @alexshalamov