[ios, macos] Initialize offline storage on main thread before snapshotting

This commit is contained in:
Minh Nguyễn
2020-04-06 09:40:10 -07:00
committed by Minh Nguyễn
parent 69ddd88512
commit 64f0a54d7f
2 changed files with 7 additions and 6 deletions

View File

@@ -301,9 +301,14 @@ private:
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."];
format:@"-[MGLMapSnapshotter startWithQueue:completionHandler:] must be called from the main thread, not %@.", NSThread.currentThread];
}
if (self.loading) {

View File

@@ -62,10 +62,6 @@ MGLImage *MGLImageFromCurrentContext() {
[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 {