Bug 233316 - Let RemoteAudioMediaStreamTrackRendererInternalUnitManager::Unit switch to VPIO unit if VPIO is running
Summary: Let RemoteAudioMediaStreamTrackRendererInternalUnitManager::Unit switch to VP...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-11-18 06:32 PST by youenn fablet
Modified: 2022-02-08 21:39 PST (History)
14 users (show)

See Also:


Attachments
Patch (35.53 KB, patch)
2021-11-18 06:49 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (39.83 KB, patch)
2021-11-19 12:38 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (39.32 KB, patch)
2021-11-22 00:43 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (39.56 KB, patch)
2021-12-01 05:45 PST, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2021-11-18 06:32:23 PST
Let RemoteAudioMediaStreamTrackRendererInternalUnitManager::Unit switch to VPIO unit if VPIO is running
Comment 1 youenn fablet 2021-11-18 06:49:24 PST
Created attachment 444668 [details]
Patch
Comment 2 youenn fablet 2021-11-18 06:51:45 PST
There are some issues with this approach.
In particular, when microphone is muted through WebKit, we keep using PlayAndRecord but switch to RemoteIO for audio rendering. We then end up in ducked audio, because of PlayAndRecord.
We need to investigate this issue further, as it seems setting PlayAndRecord but not starting VPIO should not trigger these audio level jumps.
Comment 3 youenn fablet 2021-11-19 12:38:11 PST
Created attachment 444845 [details]
Patch
Comment 4 youenn fablet 2021-11-22 00:43:50 PST
Created attachment 444950 [details]
Patch
Comment 5 Phong Le 2021-11-25 03:01:02 PST
Not only remote audio stream but also playing a media url by audio, video element during a call
Comment 6 Radar WebKit Bug Importer 2021-11-25 06:33:24 PST
<rdar://problem/85750694>
Comment 7 Eric Carlson 2021-11-30 08:47:56 PST
Comment on attachment 444950 [details]
Patch

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

> Source/WebCore/ChangeLog:9
> +        We use this in WebKit to render the MediaStreamTrackis of the process doing capture through VPIO when running.

s/MediaStreamTrackis/MediaStreamTracks/

> Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp:87
> +    setShouldProduceMicrophoneSamples(true);

Nit: it not only _should_ produce microphone samples, it _is_ producing them, so maybe `setIsProducingMicrophoneSamples` instead?

> Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp:499
> +                m_speakerSamplesProducer->captureUnitIsStopped();

Nit: The producer is called after the unit has stopped, so I think `captureUnitHasStopped` would be clearer.

> Source/WebKit/GPUProcess/GPUProcess.cpp:516
> +void GPUProcess::notifyStartCapturingAudio(GPUConnectionToWebProcess& process)

Nit: this name is slightly awkward, maybe `audioCaptureIsStarting`, or `processIsStartingToCaptureAudio` instead?

> Source/WebKit/GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererInternalUnitManager.cpp:255
> +    if (m_isPlaying)
> +        m_localUnit->stop();

This made me scratch my head for a minute so it might be worth adding a comment about why we stop the local unit when the capture unit starts.

> Source/WebKit/GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererInternalUnitManager.cpp:261
> +    if (m_isPlaying)
> +        m_localUnit->start();

Ditto
Comment 8 youenn fablet 2021-12-01 05:34:15 PST
Thanks for the review.

(In reply to Eric Carlson from comment #7)
> Comment on attachment 444950 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=444950&action=review
> 
> > Source/WebCore/ChangeLog:9
> > +        We use this in WebKit to render the MediaStreamTrackis of the process doing capture through VPIO when running.
> 
> s/MediaStreamTrackis/MediaStreamTracks/

OK

> > Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp:87
> > +    setShouldProduceMicrophoneSamples(true);
> 
> Nit: it not only _should_ produce microphone samples, it _is_ producing
> them, so maybe `setIsProducingMicrophoneSamples` instead?

Sounds good.

> > Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp:499
> > +                m_speakerSamplesProducer->captureUnitIsStopped();
> 
> Nit: The producer is called after the unit has stopped, so I think
> `captureUnitHasStopped` would be clearer.

OK

> > Source/WebKit/GPUProcess/GPUProcess.cpp:516
> > +void GPUProcess::notifyStartCapturingAudio(GPUConnectionToWebProcess& process)
> 
> Nit: this name is slightly awkward, maybe `audioCaptureIsStarting`, or
> `processIsStartingToCaptureAudio` instead?

processIsStartingToCaptureAudio sounds much better.

> > Source/WebKit/GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererInternalUnitManager.cpp:255
> > +    if (m_isPlaying)
> > +        m_localUnit->stop();
> 
> This made me scratch my head for a minute so it might be worth adding a
> comment about why we stop the local unit when the capture unit starts.
> 
> > Source/WebKit/GPUProcess/webrtc/RemoteAudioMediaStreamTrackRendererInternalUnitManager.cpp:261
> > +    if (m_isPlaying)
> > +        m_localUnit->start();
> 
> Ditto

OK, will add a comment.
Comment 9 youenn fablet 2021-12-01 05:45:33 PST
Created attachment 445565 [details]
Patch
Comment 10 EWS 2021-12-08 03:07:10 PST
Committed r286650 (244963@main): <https://commits.webkit.org/244963@main>

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