Bug 232155 - [Cocoa] Fairplay encrypted video fails to play when loaded in a display:none element
Summary: [Cocoa] Fairplay encrypted video fails to play when loaded in a display:none ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-22 10:14 PDT by Eric Carlson
Modified: 2021-10-22 20:17 PDT (History)
8 users (show)

See Also:


Attachments
Patch (12.95 KB, patch)
2021-10-22 10:24 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch (13.85 KB, patch)
2021-10-22 16:08 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch (13.83 KB, patch)
2021-10-22 16:33 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch (13.83 KB, patch)
2021-10-22 16:35 PDT, Eric Carlson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2021-10-22 10:14:35 PDT
Fairplay encrypted video can never play if it is loaded in a display:none element
Comment 1 Eric Carlson 2021-10-22 10:14:50 PDT
rdar://83419159
Comment 2 Eric Carlson 2021-10-22 10:24:50 PDT
Created attachment 442177 [details]
Patch
Comment 3 Jer Noble 2021-10-22 11:04:16 PDT
Comment on attachment 442177 [details]
Patch

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

> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:112
> +    if (!haveBeenAskedToPaint() || (supportsAcceleratedRendering() && m_player->renderingCanBeAccelerated()))
> +        return MediaRenderingMode::MediaRenderingToLayer;

So this will just cause us to always create an AVPlayerLayer immediately after the AVAssetStatus moves to > Unknown.  Is that correct?
Comment 4 Peng Liu 2021-10-22 15:21:05 PDT
Comment on attachment 442177 [details]
Patch

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

> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:637
> +    if (!m_avPlayer || m_videoLayer)

Just curious. Is it possible that we need a video layer with a different size (or content scale) than the existing video layer.
Before this change, this function will always create a new video layer and set some parameters (from the player).
Comment 5 Eric Carlson 2021-10-22 15:56:37 PDT
Comment on attachment 442177 [details]
Patch

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

>> Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:637
>> +    if (!m_avPlayer || m_videoLayer)
> 
> Just curious. Is it possible that we need a video layer with a different size (or content scale) than the existing video layer.
> Before this change, this function will always create a new video layer and set some parameters (from the player).

No, this function is only called when `m_videoLayer` is NULL so this change isn't necessary.
Comment 6 Eric Carlson 2021-10-22 16:08:12 PDT
Created attachment 442211 [details]
Patch
Comment 7 Jer Noble 2021-10-22 16:15:02 PDT
Comment on attachment 442211 [details]
Patch

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

r=me with nit

> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:112
>  
> -    if (supportsAcceleratedRendering() && m_player->renderingCanBeAccelerated())
> -        return MediaRenderingToLayer;
> +    if ((m_readyState >= MediaPlayer::ReadyState::HaveMetadata && !haveBeenAskedToPaint()) || (supportsAcceleratedRendering() && m_player->renderingCanBeAccelerated()))
> +        return MediaRenderingMode::MediaRenderingToLayer;

Nit: I might break this out into two statements for readability, and a smaller diff:

if (supportsAcceleratedRendering() && m_player->renderingCanBeAccelerated())
    return MediaRenderingToLayer;

if (m_readyState >= MediaPlayer::ReadyState::HaveMetadata && !haveBeenAskedToPaint())
    return MediaRenderingToLayer;
Comment 8 Eric Carlson 2021-10-22 16:33:36 PDT
Created attachment 442219 [details]
Patch
Comment 9 Eric Carlson 2021-10-22 16:35:59 PDT
Created attachment 442221 [details]
Patch
Comment 10 EWS 2021-10-22 19:34:26 PDT
Committed r284737 (243446@main): <https://commits.webkit.org/243446@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 442221 [details].
Comment 11 Simon Fraser (smfr) 2021-10-22 20:17:25 PDT
Comment on attachment 442221 [details]
Patch

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

> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:160
> +    enum class MediaRenderingMode : uint8_t {
> +        MediaRenderingNone,
> +        MediaRenderingToContext,
> +        MediaRenderingToLayer
> +    };

Remove "MediaRendering" from the values.