Bug 225620

Summary: [iPad] SourceBufferPrivateAVFObjC should not report an error to the web page when the video playback is interrupted
Product: WebKit Reporter: Peng Liu <peng.liu6>
Component: MediaAssignee: Peng Liu <peng.liu6>
Status: RESOLVED FIXED    
Severity: Normal CC: darin, eric.carlson, ews-watchlist, glenn, jer.noble, philipj, sergio, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Make all changes for iOS only
jer.noble: review+
Patch for landing none

Description Peng Liu 2021-05-10 15:40:35 PDT
SourceBufferPrivateAVFObjC should not report an error to the web page when the video playback is interrupted
Comment 1 Peng Liu 2021-05-10 15:45:40 PDT
<rdar://70118480>
Comment 2 Peng Liu 2021-05-10 16:03:26 PDT
Created attachment 428214 [details]
Patch
Comment 3 Darin Adler 2021-05-10 22:33:19 PDT
Comment on attachment 428214 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=428214&action=review

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:971
> +#if PLATFORM(IOS_FAMILY)
> +    if ([layer status] == AVQueuedSampleBufferRenderingStatusFailed && [[error domain] isEqualToString:@"AVFoundationErrorDomain"] && [error code] == AVErrorOperationInterrupted) {
> +        m_displayLayerWasInterrupted = true;
> +        return;
> +    }
> +#endif

Why isn’t this needed on Mac? Why are we compiling all the code to handle m_displayLayerWasInterrupted on Mac, but then not using it there?
Comment 4 Peng Liu 2021-05-11 10:00:31 PDT
Comment on attachment 428214 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=428214&action=review

>> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:971
>> +#endif
> 
> Why isn’t this needed on Mac? Why are we compiling all the code to handle m_displayLayerWasInterrupted on Mac, but then not using it there?

The bug that this patch is fixing only happens on iPads. Based on my test results, AVFoundation only reports the error (AVErrorOperationInterrupted) on iPads. Therefore, I enabled this code section for iOS only.

Potentially, other code sections related to "m_displayLayerWasInterrupted" are useful for Mac, so I did not wrap them with the macro. But it seems a good idea to compile them for iOS only because they won't be used on Mac for now.
Comment 5 Peng Liu 2021-05-11 10:38:43 PDT
Created attachment 428293 [details]
Make all changes for iOS only
Comment 6 Jer Noble 2021-05-12 10:09:49 PDT
Comment on attachment 428293 [details]
Make all changes for iOS only

View in context: https://bugs.webkit.org/attachment.cgi?id=428293&action=review

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:1206
> +#if PLATFORM(IOS_FAMILY)
> +    if (m_displayLayerWasInterrupted)
> +        return false;
> +#endif

This will block appending samples to the audio renderer as well as the display layer. Consider moving this inside the `if (trackID == m_enabledVideoTrackID)` block below.

> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:1260
> +#if PLATFORM(IOS_FAMILY)
> +    if (m_displayLayerWasInterrupted)
> +        return;
> +#endif

Ditto, and consider adding a call to `[m_displayLayer stopRequestingMediaData];` before the return.
Comment 7 Peng Liu 2021-05-12 10:59:58 PDT
Comment on attachment 428293 [details]
Make all changes for iOS only

View in context: https://bugs.webkit.org/attachment.cgi?id=428293&action=review

>> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:1206
>> +#endif
> 
> This will block appending samples to the audio renderer as well as the display layer. Consider moving this inside the `if (trackID == m_enabledVideoTrackID)` block below.

Good point! But looks like it won't impact the function, because we will want to stop appending audio samples when video is interrupted.
I will fix it anyway.

>> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:1260
>> +#endif
> 
> Ditto, and consider adding a call to `[m_displayLayer stopRequestingMediaData];` before the return.

Hmm, probably we can just remove this change. Let me have a try.
Comment 8 Peng Liu 2021-05-12 14:48:12 PDT
Created attachment 428421 [details]
Patch for landing
Comment 9 Peng Liu 2021-05-12 14:50:35 PDT
Comment on attachment 428293 [details]
Make all changes for iOS only

View in context: https://bugs.webkit.org/attachment.cgi?id=428293&action=review

>>> Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:1260
>>> +#endif
>> 
>> Ditto, and consider adding a call to `[m_displayLayer stopRequestingMediaData];` before the return.
> 
> Hmm, probably we can just remove this change. Let me have a try.

Confirmed that this change is not needed. Removed.
Comment 10 EWS 2021-05-12 22:37:25 PDT
Committed r277424 (237672@main): <https://commits.webkit.org/237672@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 428421 [details].