[ios, macos] Initialize offline storage on main thread before snapshotting
This commit is contained in:
committed by
Minh Nguyễn
parent
69ddd88512
commit
64f0a54d7f
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user