From 56657abdc47723ed8a19bd0858361c77ffa83f1b Mon Sep 17 00:00:00 2001 From: "jer.noble@apple.com" Date: Wed, 18 Apr 2018 21:17:18 +0000 Subject: [PATCH] Fix runtime errors in simulator while playing media https://bugs.webkit.org/show_bug.cgi?id=184751 Reviewed by Eric Carlson. AVURLAssetHTTPCookiesKey may not be present, and AVPlayer may not respond to certain methods. * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): (WebCore::MediaPlayerPrivateAVFoundationObjC::updateDisableExternalPlayback): (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep): git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230779 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 15 +++++++++++++++ .../objc/MediaPlayerPrivateAVFoundationObjC.mm | 12 +++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 5aef2db..82a5596 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,5 +1,20 @@ 2018-04-18 Jer Noble + Fix runtime errors in simulator while playing media + https://bugs.webkit.org/show_bug.cgi?id=184751 + + Reviewed by Eric Carlson. + + AVURLAssetHTTPCookiesKey may not be present, and AVPlayer may not respond to certain methods. + + * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: + (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): + (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): + (WebCore::MediaPlayerPrivateAVFoundationObjC::updateDisableExternalPlayback): + (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep): + +2018-04-18 Jer Noble + Ignore ASSERT when setting AVAudioSessionCategory returns an error on simulator. https://bugs.webkit.org/show_bug.cgi?id=184698 diff --git a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm index 7368f2a..2a96a8b 100644 --- a/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm +++ b/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm @@ -240,7 +240,6 @@ SOFT_LINK_POINTER(AVFoundation, AVPlayerItemLegibleOutputTextStylingResolutionSo #if ENABLE(AVF_CAPTIONS) SOFT_LINK_POINTER(AVFoundation, AVURLAssetCacheKey, NSString*) -SOFT_LINK_POINTER(AVFoundation, AVURLAssetHTTPCookiesKey, NSString*) SOFT_LINK_POINTER(AVFoundation, AVURLAssetOutOfBandAlternateTracksKey, NSString*) SOFT_LINK_POINTER(AVFoundation, AVURLAssetUsesNoPersistentCacheKey, NSString*) SOFT_LINK_POINTER(AVFoundation, AVOutOfBandAlternateTrackDisplayNameKey, NSString*) @@ -252,6 +251,7 @@ SOFT_LINK_POINTER(AVFoundation, AVOutOfBandAlternateTrackSourceKey, NSString*) SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicDescribesMusicAndSoundForAccessibility, NSString*) SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicTranscribesSpokenDialogForAccessibility, NSString*) SOFT_LINK_POINTER(AVFoundation, AVMediaCharacteristicIsAuxiliaryContent, NSString*) +SOFT_LINK_POINTER_OPTIONAL(AVFoundation, AVURLAssetHTTPCookiesKey, NSString*) #define AVURLAssetHTTPCookiesKey getAVURLAssetHTTPCookiesKey() #define AVURLAssetOutOfBandAlternateTracksKey getAVURLAssetOutOfBandAlternateTracksKey() @@ -936,7 +936,8 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const URL& url) for (auto& cookie : cookies) [nsCookies addObject:toNSHTTPCookie(cookie)]; - [options setObject:nsCookies.get() forKey:AVURLAssetHTTPCookiesKey]; + if (AVURLAssetHTTPCookiesKey) + [options setObject:nsCookies.get() forKey:AVURLAssetHTTPCookiesKey]; } #endif @@ -1018,7 +1019,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVPlayer() } #endif -#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) +#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) && !ENABLE(MINIMAL_SIMULATOR) setShouldDisableSleep(player()->shouldDisableSleep()); #endif @@ -2959,7 +2960,8 @@ void MediaPlayerPrivateAVFoundationObjC::updateDisableExternalPlayback() if (!m_avPlayer) return; - [m_avPlayer setUsesExternalPlaybackWhileExternalScreenIsActive:player()->fullscreenMode() & MediaPlayer::VideoFullscreenModeStandard]; + if ([m_avPlayer respondsToSelector:@selector(setUsesExternalPlaybackWhileExternalScreenIsActive:)]) + [m_avPlayer setUsesExternalPlaybackWhileExternalScreenIsActive:player()->fullscreenMode() & MediaPlayer::VideoFullscreenModeStandard]; #endif } @@ -3217,7 +3219,7 @@ void MediaPlayerPrivateAVFoundationObjC::canPlayFastReverseDidChange(bool newVal void MediaPlayerPrivateAVFoundationObjC::setShouldDisableSleep(bool flag) { -#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) +#if PLATFORM(IOS) && !PLATFORM(IOS_SIMULATOR) && !ENABLE(MINIMAL_SIMULATOR) [m_avPlayer _setPreventsSleepDuringVideoPlayback:flag]; #else UNUSED_PARAM(flag); -- 1.8.3.1