Skip to content

[Cocoa] Activate DisplayCaptureCapability before prompting for getDisplayMedia#64060

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
eric-carlson:screen-capture-endowment-activation
May 2, 2026
Merged

[Cocoa] Activate DisplayCaptureCapability before prompting for getDisplayMedia#64060
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
eric-carlson:screen-capture-endowment-activation

Conversation

@eric-carlson
Copy link
Copy Markdown
Contributor

@eric-carlson eric-carlson commented May 1, 2026

9ccf6f3

[Cocoa] Activate DisplayCaptureCapability before prompting for getDisplayMedia
https://bugs.webkit.org/show_bug.cgi?id=313843
rdar://176044721

Reviewed by Jer Noble.

Activate the display capture endowment while a getDisplayMedia() permission prompt is pending.

Track whether a getDisplayMedia() prompt is in progress with two new MediaProducerMediaState
bits: IsPromptingForWindowCapture and IsPromptingForScreenCapture. Include these bits in
the display capture capability activation/deactivation checks so the endowment is held for
the full duration of the prompt, not just once capture begins. Clear the prompting state
on denial, cancellation, and page invalidation, preserve it across transient media state
updates until DisplayCaptureMask is set.

Tested manually.

* Source/WebCore/page/MediaProducer.h:
* Source/WebCore/page/MediaProducer.serialization.in:
* Source/WebKit/UIProcess/Cocoa/UserMediaPermissionRequestProxyCocoa.mm:
(WebKit::UserMediaPermissionRequestProxyCocoa::invalidate):
(WebKit::UserMediaPermissionRequestProxyCocoa::promptForGetDisplayMedia):
* Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::shouldActivateDisplayCaptureCapability const):
(WebKit::WebPageProxy::shouldDeactivateDisplayCaptureCapability const):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setIsPromptingForGetDisplayMedia):
(WebKit::WebPageProxy::isPlayingMediaDidChange):
* Source/WebKit/UIProcess/WebPageProxy.h:

Canonical link: https://commits.webkit.org/312477@main

3306cce

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ⏳ 🛠 ios-apple
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ❌ 🧪 win-tests ⏳ 🛠 mac-apple
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe ⏳ 🛠 vision-apple
✅ 🧪 ios-wk2-wpt ❌ 🧪 api-mac-debug ✅ 🛠 gtk3-libwebrtc
✅ 🧪 api-ios ✅ 🧪 mac-wk1 ✅ 🛠 gtk
✅ 🛠 ios-safer-cpp ✅ 🧪 mac-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🛠 playstation
✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@eric-carlson eric-carlson requested a review from cdumez as a code owner May 1, 2026 20:34
@eric-carlson eric-carlson self-assigned this May 1, 2026
@eric-carlson eric-carlson added the Media Bugs related to the HTML 5 Media elements. label May 1, 2026
@eric-carlson
Copy link
Copy Markdown
Contributor Author

22:08:52.391 28130     TestWebKitAPI.WKInspectorExtension.EvaluateScriptInExtensionTabCanReturnPromises
22:08:52.391 28130         inspector-resource:///Base/Main.js:3189:22: CONSOLE ERROR TypeError: null is not an object (evaluating 'oldMainFrame.mainResource')

The API test failure is unrelated.

@eric-carlson eric-carlson added the merge-queue Applied to send a pull request to merge-queue label May 2, 2026
…playMedia

https://bugs.webkit.org/show_bug.cgi?id=313843
rdar://176044721

Reviewed by Jer Noble.

Activate the display capture endowment while a getDisplayMedia() permission prompt is pending.

Track whether a getDisplayMedia() prompt is in progress with two new MediaProducerMediaState
bits: IsPromptingForWindowCapture and IsPromptingForScreenCapture. Include these bits in
the display capture capability activation/deactivation checks so the endowment is held for
the full duration of the prompt, not just once capture begins. Clear the prompting state
on denial, cancellation, and page invalidation, preserve it across transient media state
updates until DisplayCaptureMask is set.

Tested manually.

* Source/WebCore/page/MediaProducer.h:
* Source/WebCore/page/MediaProducer.serialization.in:
* Source/WebKit/UIProcess/Cocoa/UserMediaPermissionRequestProxyCocoa.mm:
(WebKit::UserMediaPermissionRequestProxyCocoa::invalidate):
(WebKit::UserMediaPermissionRequestProxyCocoa::promptForGetDisplayMedia):
* Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm:
(WebKit::WebPageProxy::shouldActivateDisplayCaptureCapability const):
(WebKit::WebPageProxy::shouldDeactivateDisplayCaptureCapability const):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setIsPromptingForGetDisplayMedia):
(WebKit::WebPageProxy::isPlayingMediaDidChange):
* Source/WebKit/UIProcess/WebPageProxy.h:

Canonical link: https://commits.webkit.org/312477@main
@webkit-commit-queue webkit-commit-queue force-pushed the screen-capture-endowment-activation branch from 3306cce to 9ccf6f3 Compare May 2, 2026 15:11
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 312477@main (9ccf6f3): https://commits.webkit.org/312477@main

Reviewed commits have been landed. Closing PR #64060 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 9ccf6f3 into WebKit:main May 2, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Media Bugs related to the HTML 5 Media elements.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants