Bug 208651 - Implement setWirelessPlaybackTarget, performTaskAtMediaTime, and wouldTaintOrigin in GPUProcess
Summary: Implement setWirelessPlaybackTarget, performTaskAtMediaTime, and wouldTaintOr...
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-05 10:01 PST by Eric Carlson
Modified: 2020-03-07 15:20 PST (History)
12 users (show)

See Also:


Attachments
Patch (26.79 KB, patch)
2020-03-05 10:17 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch (26.82 KB, patch)
2020-03-05 10:25 PST, Eric Carlson
no flags Details | Formatted Diff | Diff
Patch (26.90 KB, patch)
2020-03-05 12:52 PST, Eric Carlson
youennf: review+
Details | Formatted Diff | Diff
Patch for landing (38.49 KB, patch)
2020-03-07 13:57 PST, 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 2020-03-05 10:01:20 PST
Implement setWirelessPlaybackTarget, performTaskAtMediaTime, and wouldTaintOrigin
Comment 1 Radar WebKit Bug Importer 2020-03-05 10:01:35 PST
<rdar://problem/60088298>
Comment 2 Eric Carlson 2020-03-05 10:17:55 PST
Created attachment 392592 [details]
Patch
Comment 3 Eric Carlson 2020-03-05 10:25:15 PST
Created attachment 392593 [details]
Patch
Comment 4 Eric Carlson 2020-03-05 12:52:30 PST
Created attachment 392609 [details]
Patch
Comment 5 youenn fablet 2020-03-06 08:46:15 PST
Comment on attachment 392609 [details]
Patch

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

> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:81
> +    m_performTaskAtMediaTimeCompletionHandler = nullptr;

We should call this completion handler otherwise we will get some debug assert.
Maybe the completion handler should return an Optional<Time>, WTF::null opt meaning that it was not done.

> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:797
> +void RemoteMediaPlayerProxy::performTaskAtMediaTime(MediaTime&& taskTime, WallTime&& messageTime, CompletionHandler<void(const MediaTime&)>&& completionHandler)

I don't think we need a MediaTime&& since it only contains int values. Ditto for WallTime that we can simply pass by value.

> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:808
> +    m_player->performTaskAtMediaTime([this, weakThis = makeWeakPtr(this)] {

It might be just simpler to have the lambda capture completionHandler so that we do not have to store it in m_performTaskAtMediaTimeCompletionHandler, which could be overridden by two successive RemoteMediaPlayerProxy::performTaskAtMediaTime calls.

> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:817
> +void RemoteMediaPlayerProxy::wouldTaintOrigin(struct WebCore::SecurityOriginData originData, CompletionHandler<void(Optional<bool>)>&& completionHandler)

s/struct WebCore::SecurityOriginData/const SecurityOriginData&/

> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:848
> +    if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::WouldTaintOrigin(origin.data()), Messages::RemoteMediaPlayerProxy::WouldTaintOrigin::Reply(wouldTaint), m_id))

Could there be a way to use m_cachedState to remove the sync IPC as a follow-up?

> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:1034
> +    m_performTaskAtMediaTimeCompletionHandler = WTFMove(completionHandler);

There is the risk that performTaskAtMediaTime is called twice so that we would override a non null m_performTaskAtMediaTimeCompletionHandler.
It might be simpler to just capture completionHandler in the lambda passed to sendWithAsyncReply.

> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:353
> +    bool performTaskAtMediaTime(WTF::Function<void()>&&, const MediaTime&) final;

s/WTF:://

> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:373
> +    WTF::Function<void()> m_performTaskAtMediaTimeCompletionHandler;

s/WTF:://
Comment 6 Eric Carlson 2020-03-07 13:41:45 PST
Comment on attachment 392609 [details]
Patch

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

Thanks for the review!

>> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:81
>> +    m_performTaskAtMediaTimeCompletionHandler = nullptr;
> 
> We should call this completion handler otherwise we will get some debug assert.
> Maybe the completion handler should return an Optional<Time>, WTF::null opt meaning that it was not done.

Great suggestion, I have made this change.

>> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:797
>> +void RemoteMediaPlayerProxy::performTaskAtMediaTime(MediaTime&& taskTime, WallTime&& messageTime, CompletionHandler<void(const MediaTime&)>&& completionHandler)
> 
> I don't think we need a MediaTime&& since it only contains int values. Ditto for WallTime that we can simply pass by value.

Fixed.

>> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:808
>> +    m_player->performTaskAtMediaTime([this, weakThis = makeWeakPtr(this)] {
> 
> It might be just simpler to have the lambda capture completionHandler so that we do not have to store it in m_performTaskAtMediaTimeCompletionHandler, which could be overridden by two successive RemoteMediaPlayerProxy::performTaskAtMediaTime calls.

MediaPlayerPrivateAVFoundationObjC is the only media player to implement this callback so far, and it only keeps one pending callback at a time. I have added a comment explaining this.

>> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:817
>> +void RemoteMediaPlayerProxy::wouldTaintOrigin(struct WebCore::SecurityOriginData originData, CompletionHandler<void(Optional<bool>)>&& completionHandler)
> 
> s/struct WebCore::SecurityOriginData/const SecurityOriginData&/

Oops, copy pasta FTW!

Fixed.

>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:848
>> +    if (!connection().sendSync(Messages::RemoteMediaPlayerProxy::WouldTaintOrigin(origin.data()), Messages::RemoteMediaPlayerProxy::WouldTaintOrigin::Reply(wouldTaint), m_id))
> 
> Could there be a way to use m_cachedState to remove the sync IPC as a follow-up?

As we discussed offline, this is possible for some canvas elements so I'll do that in the patch for landing. I have also added a { SecurityOriginData, Optional<bool> } cache to MediaPlayerPrivateRemote, so we will only need to make the sync call once for a given origin in any case.

>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:1034
>> +    m_performTaskAtMediaTimeCompletionHandler = WTFMove(completionHandler);
> 
> There is the risk that performTaskAtMediaTime is called twice so that we would override a non null m_performTaskAtMediaTimeCompletionHandler.
> It might be simpler to just capture completionHandler in the lambda passed to sendWithAsyncReply.

Fixed

>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:353
>> +    bool performTaskAtMediaTime(WTF::Function<void()>&&, const MediaTime&) final;
> 
> s/WTF:://

Fixed.

>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.h:373
>> +    WTF::Function<void()> m_performTaskAtMediaTimeCompletionHandler;
> 
> s/WTF:://

Removed.
Comment 7 Eric Carlson 2020-03-07 13:57:31 PST
Created attachment 392894 [details]
Patch for landing
Comment 8 WebKit Commit Bot 2020-03-07 15:20:01 PST
Comment on attachment 392894 [details]
Patch for landing

Clearing flags on attachment: 392894

Committed r258082: <https://trac.webkit.org/changeset/258082>