diff options
author | Chris Loer <chris.loer@gmail.com> | 2018-06-01 15:12:52 -0700 |
---|---|---|
committer | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2018-06-07 17:43:41 -0400 |
commit | 8118cb55037a99c22fdf86a3e7dba0398cba38eb (patch) | |
tree | 198cb6516fa1c4c1e1fa138765828bc2d602b000 | |
parent | 81179fb05e6de75e9f00e5f34d2feb2999ffb12a (diff) | |
download | qtlocation-mapboxgl-8118cb55037a99c22fdf86a3e7dba0398cba38eb.tar.gz |
[ios, macos] Fix MGLMapSnapshotter concurrency bugs (issue #11827).
- Biggest change: when we apply the watermark on a background thread, don't capture self (turn most of the related instance methods into class methods)
- Don't call mbglMapSnapshotter->snapshot from a user-provided queue, since it's an asynchronous call anyway and starting it on the user's queue requires capturing self.
# Conflicts:
# platform/darwin/src/MGLMapSnapshotter.mm
-rw-r--r-- | platform/darwin/src/MGLMapSnapshotter.mm | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/platform/darwin/src/MGLMapSnapshotter.mm b/platform/darwin/src/MGLMapSnapshotter.mm index 2a2bef8fb8..73db8ea151 100644 --- a/platform/darwin/src/MGLMapSnapshotter.mm +++ b/platform/darwin/src/MGLMapSnapshotter.mm @@ -108,11 +108,6 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; - (void)startWithQueue:(dispatch_queue_t)queue completionHandler:(MGLMapSnapshotCompletionHandler)completion { - if (!mbgl::Scheduler::GetCurrent()) { - [NSException raise:NSInvalidArgumentException - format:@"startWithQueue:completionHandler: must be called from a thread with an active run loop."]; - } - if ([self isLoading]) { [NSException raise:NSInternalInconsistencyException format:@"Already started this snapshotter."]; @@ -126,7 +121,7 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64; _snapshotCallback = std::make_unique<mbgl::Actor<mbgl::MapSnapshotter::Callback>>(*mbgl::Scheduler::GetCurrent(), [=](std::exception_ptr mbglError, mbgl::PremultipliedImage image, mbgl::MapSnapshotter::Attributions attributions, mbgl::MapSnapshotter::PointForFn pointForFn) { __typeof__(self) strongSelf = weakSelf; // If self had died, _snapshotCallback would have been destroyed and this block would not be executed - NSCAssert(strongSelf, @"Snapshot callback executed after being destroyed."); + assert(strongSelf); strongSelf.loading = false; |