[webkit-changes] [WebKit/WebKit] 411951: mediaSession.setCameraActive/setMicrophoneActive c...
youennf
noreply at github.com
Thu Sep 19 09:57:12 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 41195127df9638b14331dc90d5baed7a2d4ea636
https://github.com/WebKit/WebKit/commit/41195127df9638b14331dc90d5baed7a2d4ea636
Author: Youenn Fablet <youenn at apple.com>
Date: 2024-09-19 (Thu, 19 Sep 2024)
Changed paths:
M Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h
M Source/WebKit/UIProcess/WebPageProxy.cpp
M Source/WebKit/UIProcess/WebPageProxy.h
M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
M Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm
A Tools/TestWebKitAPI/Tests/WebKitCocoa/media-session-capture.html
Log Message:
-----------
mediaSession.setCameraActive/setMicrophoneActive callback is executed after WebPage is notified of muted state
https://bugs.webkit.org/show_bug.cgi?id=279887
rdar://problem/136219468
Reviewed by Eric Carlson.
Let's start with the following scenario:
1. User starts capturing camera and microphone
2. User mutes capture using Safari UI
3. User tries to unmute capture using MediaSession setCameraActive/setMicrophoneActive
At step 2, WebPage is notified of being muted and triggers MediaSession actions as well as mute/unmute MediaStreamTrack events.
This is all good.
At step 3, WebPageProxy will make a request to grant capture restart.
When this request is granted, WebPageProxy will first mute other pages and unmute itself.
This will trigger new MediaSession actions as well as mute/unmute MediaStreamTrack events.
It will then notify WebPage that the unmute capture request is validated.
This will trigger resolution of the MediaSession setCameraActive/setMicrophoneActive promise.
The consequence is that the order of events/actions and promise resolution is wrong.
In addition, a number of action handlers are executed even though they were not needed since unmuting was requested via setCameraActive/setMicrophoneActive.
To fix this, we add a new callback to UserMediaPermissionRequestProxy which will be called if the request is allowed but before WebPageProxy unmutes itself.
This will give a correct ordering and will remove the additional action handler calls.
Covered by added API test.
* Source/WebKit/UIProcess/UserMediaPermissionRequestProxy.h:
(WebKit::UserMediaPermissionRequestProxy::setBeforeStartingCaptureCallback):
(WebKit::UserMediaPermissionRequestProxy::Function<void):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::willStartCapture):
(WebKit::WebPageProxy::validateCaptureStateUpdate):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit/GetUserMedia.mm:
(TestWebKitAPI::(WebKit2, ToggleCaptureWhenRestarting)):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/media-session-capture.html: Added.
Canonical link: https://commits.webkit.org/283925@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list