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

Commit

Permalink
[ios, macos] Initialize offline storage on main thread before snapsho…
Browse files Browse the repository at this point in the history
…tting
  • Loading branch information
1ec5 committed Apr 7, 2020
1 parent 928f37f commit 17ad571
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 6 additions & 1 deletion platform/darwin/src/MGLMapSnapshotter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ - (void)startWithQueue:(dispatch_queue_t)queue overlayHandler:(MGLMapSnapshotOve
if (!completion) {
return;
}
if (!mbgl::Scheduler::GetCurrent()) {

// Ensure that offline storage has been initialized on the main thread, as MGLMapView and MGLOfflineStorage do when used directly.
// https://github.com/mapbox/mapbox-gl-native-ios/issues/227
if ([NSThread.currentThread isMainThread]) {
(void)[MGLOfflineStorage sharedOfflineStorage];
} else {
[NSException raise:NSInvalidArgumentException
format:@"startWithQueue:completionHandler: must be called from a thread with an active run loop."];
}
Expand Down
4 changes: 0 additions & 4 deletions platform/darwin/test/MGLMapSnapshotterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ - (void)setUp {
[super setUp];

[MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];

// Initialize file system and run loop before snapshotting.
// https://github.com/mapbox/mapbox-gl-native-ios/issues/227
(void)[MGLOfflineStorage sharedOfflineStorage];
}

- (void)tearDown {
Expand Down

0 comments on commit 17ad571

Please sign in to comment.