Bug 225826 - [GPUP] WebContent process should not pull audio session category from the GPU Process
Summary: [GPUP] WebContent process should not pull audio session category from the GPU...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Peng Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-05-14 14:36 PDT by Peng Liu
Modified: 2021-05-17 09:32 PDT (History)
10 users (show)

See Also:


Attachments
Patch (32.40 KB, patch)
2021-05-14 17:40 PDT, Peng Liu
no flags Details | Formatted Diff | Diff
Fix build failures on iOS (34.79 KB, patch)
2021-05-14 20:48 PDT, Peng Liu
darin: review+
Details | Formatted Diff | Diff
Patch for landing (34.77 KB, patch)
2021-05-16 10:52 PDT, Peng Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peng Liu 2021-05-14 14:36:51 PDT
When “Media in GPU Process” is enabled, the audio session category in the GPU Process is decided based on the audio session categories from all WebContent processes. A WebContent process can push audio session category to the GPU Process, but should not read it back.
Comment 1 Peng Liu 2021-05-14 17:40:23 PDT
Created attachment 428691 [details]
Patch
Comment 2 Peng Liu 2021-05-14 20:48:10 PDT
Created attachment 428706 [details]
Fix build failures on iOS
Comment 3 Darin Adler 2021-05-15 15:42:11 PDT
Comment on attachment 428706 [details]
Fix build failures on iOS

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

I think on balance changing this from an enum to an enum class is making things worse.

> Source/WebCore/page/DeprecatedGlobalSettings.cpp:157
> +    return (unsigned)AudioSession::sharedSession().categoryOverride();

It’s peculiar to use a C-style cast here. I suggest static_cast.

> Source/WebCore/platform/audio/AudioSession.cpp:116
> +    return return AudioSession::CategoryType::None;

This says "return return", so I don’t think it will compile.

> Source/WebCore/platform/audio/AudioSession.h:63
> -    enum CategoryType : uint8_t {
> +    enum class CategoryType : uint8_t {

Not sure this is an improvement. Does make it more wordy everywhere. Does it make the code more clear? I’m OK with it, but not sure.

> Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm:134
> +    AudioSession::CategoryType category = AudioSession::CategoryType::None;

Could use auto here to make things a little less verbose. Why write AudioSession::CategoryType twice on the same line of code unnecessarily?
Comment 4 Peng Liu 2021-05-15 18:32:36 PDT
Comment on attachment 428706 [details]
Fix build failures on iOS

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

>> Source/WebCore/page/DeprecatedGlobalSettings.cpp:157
>> +    return (unsigned)AudioSession::sharedSession().categoryOverride();
> 
> It’s peculiar to use a C-style cast here. I suggest static_cast.

Agree! Will fix it.

>> Source/WebCore/platform/audio/AudioSession.cpp:116
>> +    return return AudioSession::CategoryType::None;
> 
> This says "return return", so I don’t think it will compile.

Good catch! It is surprising that the bots did not complain.

>> Source/WebCore/platform/audio/AudioSession.h:63
>> +    enum class CategoryType : uint8_t {
> 
> Not sure this is an improvement. Does make it more wordy everywhere. Does it make the code more clear? I’m OK with it, but not sure.

Hmm, it does catch a mistake in AudioSessionIOS.mm though. The below code won't compile when we use enum class.

if (categoryOverride() && categoryOverride() != newCategory)

>> Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm:134
>> +    AudioSession::CategoryType category = AudioSession::CategoryType::None;
> 
> Could use auto here to make things a little less verbose. Why write AudioSession::CategoryType twice on the same line of code unnecessarily?

Right, will fix it.
Comment 5 Darin Adler 2021-05-15 18:50:01 PDT
Comment on attachment 428706 [details]
Fix build failures on iOS

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

>>> Source/WebCore/platform/audio/AudioSession.h:63
>>> +    enum class CategoryType : uint8_t {
>> 
>> Not sure this is an improvement. Does make it more wordy everywhere. Does it make the code more clear? I’m OK with it, but not sure.
> 
> Hmm, it does catch a mistake in AudioSessionIOS.mm though. The below code won't compile when we use enum class.
> 
> if (categoryOverride() && categoryOverride() != newCategory)

Well, that’s a pretty good argument in favor if it actually caught a mistake.
Comment 6 Peng Liu 2021-05-15 19:03:49 PDT
Comment on attachment 428706 [details]
Fix build failures on iOS

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

>>>> Source/WebCore/platform/audio/AudioSession.h:63
>>>> +    enum class CategoryType : uint8_t {
>>> 
>>> Not sure this is an improvement. Does make it more wordy everywhere. Does it make the code more clear? I’m OK with it, but not sure.
>> 
>> Hmm, it does catch a mistake in AudioSessionIOS.mm though. The below code won't compile when we use enum class.
>> 
>> if (categoryOverride() && categoryOverride() != newCategory)
> 
> Well, that’s a pretty good argument in favor if it actually caught a mistake.

I noticed it when I saw multiple "None"s in different places, e.g., AudioSession, PlatformMediaSession, and AudioStreamDescription.
To be honest I did not expect a simple change here will lead to changes in so many places. :-)
Comment 7 Peng Liu 2021-05-16 10:52:11 PDT
Created attachment 428794 [details]
Patch for landing
Comment 8 EWS 2021-05-17 09:31:48 PDT
Committed r277584 (237810@main): <https://commits.webkit.org/237810@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 428794 [details].
Comment 9 Radar WebKit Bug Importer 2021-05-17 09:32:20 PDT
<rdar://problem/78108250>