From 05fe34490eb8e8facfa22954831ec2d389c4b959 Mon Sep 17 00:00:00 2001 From: Radek Czemerys Date: Wed, 30 Oct 2019 21:06:00 +0100 Subject: [PATCH] Reverts "Timing: Fixes timer when app get into background (#24649)" This reverts commit 338298417f8077dee177057c57b38671b4ec8c75 --- React/Modules/RCTTiming.m | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/React/Modules/RCTTiming.m b/React/Modules/RCTTiming.m index bfc31c63f78dfc..8a090228628cb0 100644 --- a/React/Modules/RCTTiming.m +++ b/React/Modules/RCTTiming.m @@ -97,7 +97,6 @@ @implementation RCTTiming NSTimer *_sleepTimer; BOOL _sendIdleEvents; BOOL _inBackground; - UIBackgroundTaskIdentifier _backgroundTaskIdentifier; } @synthesize bridge = _bridge; @@ -113,7 +112,6 @@ - (void)setBridge:(RCTBridge *)bridge _paused = YES; _timers = [NSMutableDictionary new]; _inBackground = NO; - _backgroundTaskIdentifier = UIBackgroundTaskInvalid; for (NSString *name in @[UIApplicationWillResignActiveNotification, UIApplicationDidEnterBackgroundNotification, @@ -137,35 +135,10 @@ - (void)setBridge:(RCTBridge *)bridge - (void)dealloc { - [self markEndOfBackgroundTaskIfNeeded]; [_sleepTimer invalidate]; [[NSNotificationCenter defaultCenter] removeObserver:self]; } -- (void)markStartOfBackgroundTaskIfNeeded -{ - if (_backgroundTaskIdentifier == UIBackgroundTaskInvalid) { - __weak typeof(self) weakSelf = self; - // Marks the beginning of a new long-running background task. We can run the timer in the background. - _backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"rct.timing.gb.task" expirationHandler:^{ - typeof(self) strongSelf = weakSelf; - if (!strongSelf) { - return; - } - // Mark the end of background task - [strongSelf markEndOfBackgroundTaskIfNeeded]; - }]; - } -} - -- (void)markEndOfBackgroundTaskIfNeeded -{ - if (_backgroundTaskIdentifier != UIBackgroundTaskInvalid) { - [[UIApplication sharedApplication] endBackgroundTask:_backgroundTaskIdentifier]; - _backgroundTaskIdentifier = UIBackgroundTaskInvalid; - } -} - - (dispatch_queue_t)methodQueue { return RCTJSThread; @@ -190,7 +163,6 @@ - (void)appDidMoveToBackground - (void)appDidMoveToForeground { - [self markEndOfBackgroundTaskIfNeeded]; _inBackground = NO; [self startTimers]; } @@ -288,7 +260,6 @@ - (void)didUpdateFrame:(RCTFrameUpdate *)update } if (_inBackground) { if (timerCount) { - [self markStartOfBackgroundTaskIfNeeded]; [self scheduleSleepTimer:nextScheduledTarget]; } } else if (!_sendIdleEvents && timersToCall.count == 0) { @@ -367,7 +338,6 @@ - (void)timerDidFire } if (_inBackground) { - [self markStartOfBackgroundTaskIfNeeded]; [self scheduleSleepTimer:timer.target]; } else if (_paused) { if ([timer.target timeIntervalSinceNow] > kMinimumSleepInterval) {