From a6368d17c5ec52355f332d869996a1946535826f Mon Sep 17 00:00:00 2001 From: JT Teh Date: Thu, 28 Sep 2017 11:00:39 -0700 Subject: [PATCH] Fix occassional hang in iOS 11 when calling VTDecompressionSessionInvalidate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG=webrtc:8302 Change-Id: I426116c621c53a0300f87a2a5dc147578b559ed6 Reviewed-on: https://webrtc-review.googlesource.com/4520 Reviewed-by: Zeke Chin Reviewed-by: Kári Helgason Commit-Queue: JT Teh Cr-Commit-Position: refs/heads/master@{#20026} --- sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm | 4 ++++ .../Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm | 6 ++++++ sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h | 1 + 3 files changed, 11 insertions(+) diff --git a/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm b/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm index 94faf53506..01905d99eb 100644 --- a/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm +++ b/sdk/objc/Framework/Classes/Common/UIDevice+RTCDevice.mm @@ -173,4 +173,8 @@ return [self currentDeviceSystemVersion] >= 9.0; } ++ (BOOL)isIOS11OrLater { + return [self currentDeviceSystemVersion] >= 11.0; +} + @end diff --git a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm index 6e000ab747..4cf48bd9c4 100644 --- a/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm +++ b/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoDecoderH264.mm @@ -25,6 +25,7 @@ #if defined(WEBRTC_IOS) #import "Common/RTCUIApplicationStatusObserver.h" +#import "WebRTC/UIDevice+RTCDevice.h" #endif // Struct that we pass to the decoder per frame to decode. We receive it again @@ -236,6 +237,11 @@ void decompressionOutputCallback(void *decoder, - (void)destroyDecompressionSession { if (_decompressionSession) { +#if defined(WEBRTC_IOS) + if ([UIDevice isIOS11OrLater]) { + VTDecompressionSessionWaitForAsynchronousFrames(_decompressionSession); + } +#endif VTDecompressionSessionInvalidate(_decompressionSession); CFRelease(_decompressionSession); _decompressionSession = nullptr; diff --git a/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h b/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h index 29e4801b2e..7e01c47f39 100644 --- a/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h +++ b/sdk/objc/Framework/Headers/WebRTC/UIDevice+RTCDevice.h @@ -60,5 +60,6 @@ typedef NS_ENUM(NSInteger, RTCDeviceType) { + (RTCDeviceType)deviceType; + (NSString *)stringForDeviceType:(RTCDeviceType)deviceType; + (BOOL)isIOS9OrLater; ++ (BOOL)isIOS11OrLater; @end