Bug 226761 - MediaPlayerPrivateRemote::didLoadingProgress should not send synchronous message to GPU process
Summary: MediaPlayerPrivateRemote::didLoadingProgress should not send synchronous mess...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jean-Yves Avenard [:jya]
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-06-08 01:30 PDT by Jean-Yves Avenard [:jya]
Modified: 2021-06-08 21:38 PDT (History)
12 users (show)

See Also:


Attachments
Patch (10.95 KB, patch)
2021-06-08 02:34 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff
Patch (10.80 KB, patch)
2021-06-08 18:37 PDT, Jean-Yves Avenard [:jya]
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Yves Avenard [:jya] 2021-06-08 01:30:28 PDT
MediaPlayerPrivateRemote::didLoadingProgress should not send synchronous message to GPU process
Comment 1 Jean-Yves Avenard [:jya] 2021-06-08 01:31:24 PDT
rdar://78834312
Comment 2 Jean-Yves Avenard [:jya] 2021-06-08 02:34:41 PDT
Created attachment 430821 [details]
Patch
Comment 3 Chris Dumez 2021-06-08 15:56:49 PDT
Comment on attachment 430821 [details]
Patch

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

> Source/WebCore/platform/graphics/MediaPlayer.h:428
> +    using DidLoadingProgressCompletionHandler = CompletionHandler<void(bool)>;

Not sure why we need this alias considering it is longer than the underlying type.

> Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:271
> +    m_player->didLoadingProgress([completionHandler = WTFMove(completionHandler)](bool progress) mutable {

Can't this be simplified as:
m_player->didLoadingProgress(WTFMove(completionHandler));
?

> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:288
> +    ASSERT(false, "Should always be using didLoadingProgressAsync");

ASSERT_NOT_REACHED()

> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:294
> +    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), [callback = WTFMove(callback)](bool progress) mutable {

can this be:
connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), WTFMove(callback), m_id);
?
Comment 4 Chris Dumez 2021-06-08 15:57:36 PDT
(In reply to Chris Dumez from comment #3)
> Comment on attachment 430821 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=430821&action=review
> 
> > Source/WebCore/platform/graphics/MediaPlayer.h:428
> > +    using DidLoadingProgressCompletionHandler = CompletionHandler<void(bool)>;
> 
> Not sure why we need this alias considering it is longer than the underlying
> type.
> 
> > Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp:271
> > +    m_player->didLoadingProgress([completionHandler = WTFMove(completionHandler)](bool progress) mutable {
> 
> Can't this be simplified as:
> m_player->didLoadingProgress(WTFMove(completionHandler));
> ?
> 
> > Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:288
> > +    ASSERT(false, "Should always be using didLoadingProgressAsync");
> 
> ASSERT_NOT_REACHED()

or ASSERT_NOT_REACHED_WITH_MESSAGE("Should always be using didLoadingProgressAsync")

> 
> > Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:294
> > +    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), [callback = WTFMove(callback)](bool progress) mutable {
> 
> can this be:
> connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::
> DidLoadingProgress(), WTFMove(callback), m_id);
> ?
Comment 5 Jean-Yves Avenard [:jya] 2021-06-08 16:23:13 PDT
Comment on attachment 430821 [details]
Patch

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

>>> Source/WebCore/platform/graphics/MediaPlayer.h:428
>>> +    using DidLoadingProgressCompletionHandler = CompletionHandler<void(bool)>;
>> 
>> Not sure why we need this alias considering it is longer than the underlying type.
> 
> or ASSERT_NOT_REACHED_WITH_MESSAGE("Should always be using didLoadingProgressAsync")

so if we ever change the type in the future, you don't have to edit it everywhere. I think it's good practice.
Comment 6 Chris Dumez 2021-06-08 16:25:32 PDT
(In reply to Jean-Yves Avenard [:jya] from comment #5)
> Comment on attachment 430821 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=430821&action=review
> 
> >>> Source/WebCore/platform/graphics/MediaPlayer.h:428
> >>> +    using DidLoadingProgressCompletionHandler = CompletionHandler<void(bool)>;
> >> 
> >> Not sure why we need this alias considering it is longer than the underlying type.
> > 
> > or ASSERT_NOT_REACHED_WITH_MESSAGE("Should always be using didLoadingProgressAsync")
> 
> so if we ever change the type in the future, you don't have to edit it
> everywhere. I think it's good practice.

OK, if that's your preference. I don't feel strongly about having an alias or not.
Comment 7 Jean-Yves Avenard [:jya] 2021-06-08 17:26:11 PDT
Comment on attachment 430821 [details]
Patch

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

>>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:294
>>> +    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), [callback = WTFMove(callback)](bool progress) mutable {
>> 
>> can this be:
>> connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), WTFMove(callback), m_id);
>> ?
> 
> 

It can.
I guess, conceptually I've seen them as different, it just happens to be the same underlying type.
Comment 8 Chris Dumez 2021-06-08 17:44:58 PDT
(In reply to Jean-Yves Avenard [:jya] from comment #7)
> Comment on attachment 430821 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=430821&action=review
> 
> >>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:294
> >>> +    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), [callback = WTFMove(callback)](bool progress) mutable {
> >> 
> >> can this be:
> >> connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), WTFMove(callback), m_id);
> >> ?
> > 
> > 
> 
> It can.
> I guess, conceptually I've seen them as different, it just happens to be the
> same underlying type.

If you create a lambda whose only thing it does is calling a lambda, then it's a tell-tell sign you may not need to wrap the lambda.
Comment 9 Jean-Yves Avenard [:jya] 2021-06-08 17:57:46 PDT
Comment on attachment 430821 [details]
Patch

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

>>>>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:294
>>>>> +    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), [callback = WTFMove(callback)](bool progress) mutable {
>>>> 
>>>> can this be:
>>>> connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), WTFMove(callback), m_id);
>>>> ?
>>> 
>>> 
>> 
>> It can.
>> I guess, conceptually I've seen them as different, it just happens to be the same underlying type.
> 
> If you create a lambda whose only thing it does is calling a lambda, then it's a tell-tell sign you may not need to wrap the lambda.

There are so many ways you can define a template with varying parameters; yet they are to be used in the same manner, that it's unfortunately far from being the norm. 
Luckily, WK's IPC bindings makes it much easier than the ones I'm used to work with.
Comment 10 Jean-Yves Avenard [:jya] 2021-06-08 18:04:56 PDT
Comment on attachment 430821 [details]
Patch

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

>>>>>> Source/WebKit/WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp:294
>>>>>> +    connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), [callback = WTFMove(callback)](bool progress) mutable {
>>>>> 
>>>>> can this be:
>>>>> connection().sendWithAsyncReply(Messages::RemoteMediaPlayerProxy::DidLoadingProgress(), WTFMove(callback), m_id);
>>>>> ?
>>>> 
>>>> 
>>> 
>>> It can.
>>> I guess, conceptually I've seen them as different, it just happens to be the same underlying type.
>> 
>> If you create a lambda whose only thing it does is calling a lambda, then it's a tell-tell sign you may not need to wrap the lambda.
> 
> There are so many ways you can define a template with varying parameters; yet they are to be used in the same manner, that it's unfortunately far from being the norm. 
> Luckily, WK's IPC bindings makes it much easier than the ones I'm used to work with.

I meant earlier: conceptually, the IPC's method is called with DidLoadingProgressAsyncReply, the other MediaPlayer::DidLoadingProgressCompletionHandler&
Comment 11 Jean-Yves Avenard [:jya] 2021-06-08 18:37:53 PDT
Created attachment 430932 [details]
Patch
Comment 12 EWS 2021-06-08 21:38:42 PDT
Committed r278646 (238628@main): <https://commits.webkit.org/238628@main>

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