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

Commit

Permalink
Remove pausing of file sources in background (#639)
Browse files Browse the repository at this point in the history
This behavior was introduced in response to a crash in 2016, but has led
to watchdog terminations when apps enter the background. Subsequent
refactoring to the file source implementations makes this behavior
unnecessary. Equivalent behavior was also removed from Maps SDK v10
(mapbox-maps-ios).
  • Loading branch information
macdrevx authored Nov 1, 2021
1 parent ab0cf28 commit 7d64e37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 28 deletions.
28 changes: 0 additions & 28 deletions platform/darwin/src/MGLOfflineStorage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ @interface MGLOfflineStorage ()
@property (nonatomic) std::shared_ptr<mbgl::DatabaseFileSource> mbglDatabaseFileSource;
@property (nonatomic) std::shared_ptr<mbgl::FileSource> mbglOnlineFileSource;
@property (nonatomic) std::shared_ptr<mbgl::FileSource> mbglFileSource;
@property (nonatomic, getter=isPaused) BOOL paused;
@end

@implementation MGLOfflineStorage {
Expand All @@ -63,10 +62,6 @@ + (instancetype)sharedOfflineStorage {
static MGLOfflineStorage *sharedOfflineStorage;
dispatch_once(&onceToken, ^{
sharedOfflineStorage = [[self alloc] init];
#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
[[NSNotificationCenter defaultCenter] addObserver:sharedOfflineStorage selector:@selector(unpauseFileSource:) name:UIApplicationWillEnterForegroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:sharedOfflineStorage selector:@selector(pauseFileSource:) name:UIApplicationDidEnterBackgroundNotification object:nil];
#endif
[sharedOfflineStorage reloadPacks];
});

Expand All @@ -80,28 +75,6 @@ + (instancetype)sharedOfflineStorage {
return sharedOfflineStorage;
}

#if TARGET_OS_IPHONE || TARGET_OS_SIMULATOR
- (void)pauseFileSource:(__unused NSNotification *)notification {
if (self.isPaused) {
return;
}

_mbglOnlineFileSource->pause();
_mbglDatabaseFileSource->pause();
self.paused = YES;
}

- (void)unpauseFileSource:(__unused NSNotification *)notification {
if (!self.isPaused) {
return;
}

_mbglOnlineFileSource->resume();
_mbglDatabaseFileSource->resume();
self.paused = NO;
}
#endif

- (void)setDelegate:(id<MGLOfflineStorageDelegate>)newValue {
MGLLogDebug(@"Setting delegate: %@", newValue);
_delegate = newValue;
Expand Down Expand Up @@ -188,7 +161,6 @@ - (instancetype)init {
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[[MGLAccountManager sharedManager] removeObserver:self forKeyPath:@"apiBaseURL"];
[[MGLAccountManager sharedManager] removeObserver:self forKeyPath:@"accessToken"];

Expand Down
4 changes: 4 additions & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Mapbox welcomes participation and contributions from everyone. Please read [CONTRIBUTING.md](../../CONTRIBUTING.md) to get started.

## main

* Fixed watchdog termination caused by pausing file sources when entering the background. ([#639](https://github.com/mapbox/mapbox-gl-native-ios/pull/639))

## 6.4.0 - September 27, 2021

This version does not support Apple Silicon Macs (arm64).
Expand Down

0 comments on commit 7d64e37

Please sign in to comment.