From b2d2489e81f944505baf64365a41e078cb44b9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A1ri=20Tristan=20Helgason?= Date: Tue, 11 Sep 2018 11:31:38 +0200 Subject: [PATCH] Remove RTCUIApplicationStatusObserver. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This component was added to work around an issue in iOS 8, which is no longer supported by WebRTC. It's removal is made more urgent by the fact that it prevents WebRTC being used by iOS extensions. Bug: webrtc:9335 Change-Id: I2a3327534fe6d5014c34a9e908096d825e8149e3 Reviewed-on: https://webrtc-review.googlesource.com/87822 Reviewed-by: Anders Carlsson Reviewed-by: Patrik Höglund Commit-Queue: Kári Helgason Cr-Commit-Position: refs/heads/master@{#24688} --- sdk/BUILD.gn | 3 - .../Common/RTCUIApplicationStatusObserver.h | 11 -- .../video_codec/RTCVideoDecoderH264.mm | 7 -- .../helpers/RTCUIApplicationStatusObserver.h | 25 ---- .../helpers/RTCUIApplicationStatusObserver.m | 114 ------------------ test/ios/test_support.mm | 6 - 6 files changed, 166 deletions(-) delete mode 100644 sdk/objc/Framework/Classes/Common/RTCUIApplicationStatusObserver.h delete mode 100644 sdk/objc/helpers/RTCUIApplicationStatusObserver.h delete mode 100644 sdk/objc/helpers/RTCUIApplicationStatusObserver.m diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 95750fceac..36909e26ae 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -122,8 +122,6 @@ if (is_ios || is_mac) { "objc/helpers/RTCDispatcher+Private.h", "objc/helpers/RTCDispatcher.h", "objc/helpers/RTCDispatcher.m", - "objc/helpers/RTCUIApplicationStatusObserver.h", - "objc/helpers/RTCUIApplicationStatusObserver.m", "objc/helpers/scoped_cftyperef.h", ] @@ -931,7 +929,6 @@ if (is_ios || is_mac) { rtc_source_set("legacy_header_paths") { sources = [ "objc/Framework/Classes/Common/NSString+StdString.h", - "objc/Framework/Classes/Common/RTCUIApplicationStatusObserver.h", "objc/Framework/Classes/Common/scoped_cftyperef.h", "objc/Framework/Classes/PeerConnection/RTCConfiguration+Native.h", "objc/Framework/Classes/PeerConnection/RTCPeerConnection+Native.h", diff --git a/sdk/objc/Framework/Classes/Common/RTCUIApplicationStatusObserver.h b/sdk/objc/Framework/Classes/Common/RTCUIApplicationStatusObserver.h deleted file mode 100644 index f380d3f3de..0000000000 --- a/sdk/objc/Framework/Classes/Common/RTCUIApplicationStatusObserver.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2016 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#import "helpers/RTCUIApplicationStatusObserver.h" diff --git a/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm b/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm index 2fa123b769..a6edbc8474 100644 --- a/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm +++ b/sdk/objc/components/video_codec/RTCVideoDecoderH264.mm @@ -76,13 +76,6 @@ void decompressionOutputCallback(void *decoderRef, OSStatus _error; } -- (instancetype)init { - if (self = [super init]) { - } - - return self; -} - - (void)dealloc { [self destroyDecompressionSession]; [self setVideoFormat:nullptr]; diff --git a/sdk/objc/helpers/RTCUIApplicationStatusObserver.h b/sdk/objc/helpers/RTCUIApplicationStatusObserver.h deleted file mode 100644 index 0c032953be..0000000000 --- a/sdk/objc/helpers/RTCUIApplicationStatusObserver.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2016 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#if defined(WEBRTC_IOS) - -#import - -NS_EXTENSION_UNAVAILABLE_IOS("Application status not available in app extensions.") -@interface RTCUIApplicationStatusObserver : NSObject - -+ (instancetype)sharedInstance; -+ (void)prepareForUse; - -- (BOOL)isApplicationActive; - -@end - -#endif // WEBRTC_IOS diff --git a/sdk/objc/helpers/RTCUIApplicationStatusObserver.m b/sdk/objc/helpers/RTCUIApplicationStatusObserver.m deleted file mode 100644 index 37554e719f..0000000000 --- a/sdk/objc/helpers/RTCUIApplicationStatusObserver.m +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2016 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "RTCUIApplicationStatusObserver.h" - -#if defined(WEBRTC_IOS) - -#import - -#include "rtc_base/checks.h" - -@interface RTCUIApplicationStatusObserver () - -@property(nonatomic, assign) BOOL initialized; -@property(nonatomic, assign) UIApplicationState state; - -@end - -@implementation RTCUIApplicationStatusObserver { - BOOL _initialized; - dispatch_block_t _initializeBlock; - dispatch_semaphore_t _waitForInitializeSemaphore; - UIApplicationState _state; - - id _activeObserver; - id _backgroundObserver; -} - -@synthesize initialized = _initialized; -@synthesize state = _state; - -+ (instancetype)sharedInstance { - static id sharedInstance; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedInstance = [[self alloc] init]; - }); - - return sharedInstance; -} - -// Method to make sure observers are added and the initialization block is -// scheduled to run on the main queue. -+ (void)prepareForUse { - __unused RTCUIApplicationStatusObserver *observer = [self sharedInstance]; -} - -- (id)init { - if (self = [super init]) { - NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - __weak RTCUIApplicationStatusObserver *weakSelf = self; - _activeObserver = [center addObserverForName:UIApplicationDidBecomeActiveNotification - object:nil - queue:[NSOperationQueue mainQueue] - usingBlock:^(NSNotification *note) { - weakSelf.state = - [UIApplication sharedApplication].applicationState; - }]; - - _backgroundObserver = [center addObserverForName:UIApplicationDidEnterBackgroundNotification - object:nil - queue:[NSOperationQueue mainQueue] - usingBlock:^(NSNotification *note) { - weakSelf.state = - [UIApplication sharedApplication].applicationState; - }]; - - _waitForInitializeSemaphore = dispatch_semaphore_create(1); - _initialized = NO; - _initializeBlock = dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS, ^{ - weakSelf.state = [UIApplication sharedApplication].applicationState; - weakSelf.initialized = YES; - }); - - dispatch_async(dispatch_get_main_queue(), _initializeBlock); - } - - return self; -} - -- (void)dealloc { - NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; - [center removeObserver:_activeObserver]; - [center removeObserver:_backgroundObserver]; -} - -- (BOOL)isApplicationActive { - // NOTE: The function `dispatch_block_wait` can only legally be called once. - // Because of this, if several threads call the `isApplicationActive` method before - // the `_initializeBlock` has been executed, instead of multiple threads calling - // `dispatch_block_wait`, the other threads need to wait for the first waiting thread - // instead. - if (!_initialized) { - dispatch_semaphore_wait(_waitForInitializeSemaphore, DISPATCH_TIME_FOREVER); - if (!_initialized) { - long ret = dispatch_block_wait(_initializeBlock, - dispatch_time(DISPATCH_TIME_NOW, 10.0 * NSEC_PER_SEC)); - RTC_DCHECK_EQ(ret, 0); - } - dispatch_semaphore_signal(_waitForInitializeSemaphore); - } - return _state == UIApplicationStateActive; -} - -@end - -#endif // WEBRTC_IOS diff --git a/test/ios/test_support.mm b/test/ios/test_support.mm index b471d137d0..fec5978854 100644 --- a/test/ios/test_support.mm +++ b/test/ios/test_support.mm @@ -14,7 +14,6 @@ #include "test/testsupport/perf_test.h" #import "sdk/objc/helpers/NSString+StdString.h" -#import "sdk/objc/helpers/RTCUIApplicationStatusObserver.h" // Springboard will kill any iOS app that fails to check in after launch within // a given time. Starting a UIApplication before invoking TestSuite::Run @@ -65,11 +64,6 @@ static bool g_save_chartjson_result; // root view controller. Set an empty one here. [_window setRootViewController:[[UIViewController alloc] init]]; - // We want to call `RTCUIApplicationStatusObserver sharedInstance` as early as - // possible in the application lifecycle to set observation properly. - __unused RTCUIApplicationStatusObserver *observer = - [RTCUIApplicationStatusObserver sharedInstance]; - // Queue up the test run. [self performSelector:@selector(runTests) withObject:nil afterDelay:0.1]; return YES;