Skip to content

[iOS] Propagate visibility during fullscreen video layer hosting#66351

Merged
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
aestes:eng/iOS-Propagate-visibility-during-fullscreen-video-layer-hosting
Jun 4, 2026
Merged

[iOS] Propagate visibility during fullscreen video layer hosting#66351
webkit-commit-queue merged 1 commit into
WebKit:mainfrom
aestes:eng/iOS-Propagate-visibility-during-fullscreen-video-layer-hosting

Conversation

@aestes
Copy link
Copy Markdown
Contributor

@aestes aestes commented Jun 3, 2026

23a2f28

[iOS] Propagate visibility during fullscreen video layer hosting
https://bugs.webkit.org/show_bug.cgi?id=316184
rdar://175469152

Reviewed by Jer Noble.

When WebKit's fullscreen video layer is hosted in another process, the UI process and
auxiliary processes should be considered visible for the duration of the fullscreen
presentation. The existing mechanism for visibility propagation (WKVisibilityPropagationView)
relies on the web view being in a visible scene, and while the app hosting the video layer does
propagate a visibility endowment to the UI process, WKVisibilityPropagationView does not further
propagate visibility to the auxiliary processes if the web view itself is not visible.

To address this, introduced LayerHostingVisibilityPropagator. It propagates a hereditary visibility
endowment grant to each auxiliary process for every visibility endowment granted to the UI process.
It also takes a MediaPlayback process assertion on the UI process for the duration of the fullscreen
layer presentation (to account for the lack of a visible scene assertion).

To detect which source environments currently hold the endowment, EndowmentStateTracker now
requests RBSProcessStateValueEndowmentInfos and walks RBSProcessEndowmentInfo entries instead of
just namespaces, allowing it to record the source environment per visibility grant and notify
clients via a new visibilityEndowmentEnvironmentsChanged() callback.

VideoPresentationManagerProxy creates a propagator during fullscreen setup, attaches it to the
VideoPresentationModel, and removes it during cleanup. WKContentView keeps a WeakHashSet of active
propagators and updates them alongside the existing WKVisibilityPropagationViews as auxiliary
processes launch and exit.

* Source/WebKit/Platform/spi/ios/BaseBoardSPI.h:
* Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h:
(+[RBSProcessPredicate predicateMatchingHandle:]):
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.h:
* Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.mm:
(WebKit::VideoPresentationModelContext::setLayerHostingVisibilityPropagator):
(WebKit::VideoPresentationManagerProxy::setupFullscreenWithID):
(WebKit::VideoPresentationManagerProxy::didCleanupFullscreen):
* Source/WebKit/UIProcess/EndowmentStateTracker.h:
(WebKit::EndowmentStateTrackerClient::visibilityEndowmentEnvironmentsChanged):
(WebKit::EndowmentStateTracker::visibilityEndowmentEnvironments const):
* Source/WebKit/UIProcess/EndowmentStateTracker.mm:
(WebKit::handleForPID):
(WebKit::EndowmentStateTracker::stateFromProcessState):
(WebKit::EndowmentStateTracker::isApplicationForeground):
(WebKit::EndowmentStateTracker::stateForHandle):
(WebKit::EndowmentStateTracker::registerMonitorIfNecessary):
(WebKit::EndowmentStateTracker::ensureState const const):
(WebKit::EndowmentStateTracker::setState):
(): Deleted.
(WebKit::EndowmentStateTracker::stateFromEndowments): Deleted.
* Source/WebKit/UIProcess/PageClient.h:
(WebKit::PageClient::createLayerHostingVisibilityPropagator):
* Source/WebKit/UIProcess/ios/LayerHostingVisibilityPropagator.h: Added.
* Source/WebKit/UIProcess/ios/LayerHostingVisibilityPropagator.mm: Added.
(WebKit::invalidateInjectors):
(WebKit::LayerHostingVisibilityPropagator::create):
(WebKit::LayerHostingVisibilityPropagator::LayerHostingVisibilityPropagator):
(WebKit::LayerHostingVisibilityPropagator::~LayerHostingVisibilityPropagator):
(WebKit::LayerHostingVisibilityPropagator::propagateVisibilityToProcess):
(WebKit::LayerHostingVisibilityPropagator::stopPropagatingVisibilityToProcess):
(WebKit::LayerHostingVisibilityPropagator::clear):
(WebKit::LayerHostingVisibilityPropagator::visibilityEndowmentEnvironmentsChanged):
(WebKit::LayerHostingVisibilityPropagator::refreshInjectorsAtIndex):
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::createLayerHostingVisibilityPropagator):
* Source/WebKit/UIProcess/ios/WKContentView.h:
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _setupVisibilityPropagationForWebProcess:contextID:]):
(-[WKContentView _removeVisibilityPropagationForWebProcess:]):
(-[WKContentView _setupVisibilityPropagationForGPUProcess]):
(-[WKContentView _setupVisibilityPropagationForModelProcess]):
(-[WKContentView _removeVisibilityPropagationViewForGPUProcess]):
(-[WKContentView _removeVisibilityPropagationViewForModelProcess]):
(-[WKContentView _resetVisibilityPropagation]):
(-[WKContentView _createLayerHostingVisibilityPropagator]):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

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

6895f50

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows Apple Internal
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win ❌ 🛠 ios-apple
✅ 🛠 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 ✅ 🛠 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 ✅ 🧪 mac-site-isolation
✅ 🛠 watch
✅ 🛠 watch-sim

@aestes aestes requested a review from cdumez as a code owner June 3, 2026 06:53
@aestes aestes self-assigned this Jun 3, 2026
@aestes aestes added the Media Bugs related to the HTML 5 Media elements. label Jun 3, 2026
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 3, 2026
@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

iOS Safer C++ Build #30645 (ec7b139)

❌ Found 1 failing file with 3 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@aestes aestes removed the merging-blocked Applied to prevent a change from being merged label Jun 3, 2026
@aestes aestes force-pushed the eng/iOS-Propagate-visibility-during-fullscreen-video-layer-hosting branch from ec7b139 to eea23f3 Compare June 3, 2026 18:32
@aestes aestes requested a review from a team June 3, 2026 18:41
Copy link
Copy Markdown
Contributor

@jernoble jernoble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me with nits

Comment thread Source/WebKit/UIProcess/ios/LayerHostingVisibilityPropagator.mm Outdated
Comment thread Source/WebKit/UIProcess/ios/LayerHostingVisibilityPropagator.mm
@webkit-ews-buildbot
Copy link
Copy Markdown
Collaborator

iOS Safer C++ Build #30751 (eea23f3)

❌ Found 1 failing file with 3 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming.
(cc @rniwa)

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Jun 3, 2026
@aestes aestes removed the merging-blocked Applied to prevent a change from being merged label Jun 3, 2026
@aestes aestes force-pushed the eng/iOS-Propagate-visibility-during-fullscreen-video-layer-hosting branch from eea23f3 to 6895f50 Compare June 3, 2026 21:43
@aestes aestes added the merge-queue Applied to send a pull request to merge-queue label Jun 4, 2026
https://bugs.webkit.org/show_bug.cgi?id=316184
rdar://175469152

Reviewed by Jer Noble.

When WebKit's fullscreen video layer is hosted in another process, the UI process and
auxiliary processes should be considered visible for the duration of the fullscreen
presentation. The existing mechanism for visibility propagation (WKVisibilityPropagationView)
relies on the web view being in a visible scene, and while the app hosting the video layer does
propagate a visibility endowment to the UI process, WKVisibilityPropagationView does not further
propagate visibility to the auxiliary processes if the web view itself is not visible.

To address this, introduced LayerHostingVisibilityPropagator. It propagates a hereditary visibility
endowment grant to each auxiliary process for every visibility endowment granted to the UI process.
It also takes a MediaPlayback process assertion on the UI process for the duration of the fullscreen
layer presentation (to account for the lack of a visible scene assertion).

To detect which source environments currently hold the endowment, EndowmentStateTracker now
requests RBSProcessStateValueEndowmentInfos and walks RBSProcessEndowmentInfo entries instead of
just namespaces, allowing it to record the source environment per visibility grant and notify
clients via a new visibilityEndowmentEnvironmentsChanged() callback.

VideoPresentationManagerProxy creates a propagator during fullscreen setup, attaches it to the
VideoPresentationModel, and removes it during cleanup. WKContentView keeps a WeakHashSet of active
propagators and updates them alongside the existing WKVisibilityPropagationViews as auxiliary
processes launch and exit.

* Source/WebKit/Platform/spi/ios/BaseBoardSPI.h:
* Source/WebKit/Platform/spi/ios/RunningBoardServicesSPI.h:
(+[RBSProcessPredicate predicateMatchingHandle:]):
* Source/WebKit/SourcesCocoa.txt:
* Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.h:
* Source/WebKit/UIProcess/Cocoa/VideoPresentationManagerProxy.mm:
(WebKit::VideoPresentationModelContext::setLayerHostingVisibilityPropagator):
(WebKit::VideoPresentationManagerProxy::setupFullscreenWithID):
(WebKit::VideoPresentationManagerProxy::didCleanupFullscreen):
* Source/WebKit/UIProcess/EndowmentStateTracker.h:
(WebKit::EndowmentStateTrackerClient::visibilityEndowmentEnvironmentsChanged):
(WebKit::EndowmentStateTracker::visibilityEndowmentEnvironments const):
* Source/WebKit/UIProcess/EndowmentStateTracker.mm:
(WebKit::handleForPID):
(WebKit::EndowmentStateTracker::stateFromProcessState):
(WebKit::EndowmentStateTracker::isApplicationForeground):
(WebKit::EndowmentStateTracker::stateForHandle):
(WebKit::EndowmentStateTracker::registerMonitorIfNecessary):
(WebKit::EndowmentStateTracker::ensureState const const):
(WebKit::EndowmentStateTracker::setState):
(): Deleted.
(WebKit::EndowmentStateTracker::stateFromEndowments): Deleted.
* Source/WebKit/UIProcess/PageClient.h:
(WebKit::PageClient::createLayerHostingVisibilityPropagator):
* Source/WebKit/UIProcess/ios/LayerHostingVisibilityPropagator.h: Added.
* Source/WebKit/UIProcess/ios/LayerHostingVisibilityPropagator.mm: Added.
(WebKit::invalidateInjectors):
(WebKit::LayerHostingVisibilityPropagator::create):
(WebKit::LayerHostingVisibilityPropagator::LayerHostingVisibilityPropagator):
(WebKit::LayerHostingVisibilityPropagator::~LayerHostingVisibilityPropagator):
(WebKit::LayerHostingVisibilityPropagator::propagateVisibilityToProcess):
(WebKit::LayerHostingVisibilityPropagator::stopPropagatingVisibilityToProcess):
(WebKit::LayerHostingVisibilityPropagator::clear):
(WebKit::LayerHostingVisibilityPropagator::visibilityEndowmentEnvironmentsChanged):
(WebKit::LayerHostingVisibilityPropagator::refreshInjectorsAtIndex):
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::createLayerHostingVisibilityPropagator):
* Source/WebKit/UIProcess/ios/WKContentView.h:
* Source/WebKit/UIProcess/ios/WKContentView.mm:
(-[WKContentView _setupVisibilityPropagationForWebProcess:contextID:]):
(-[WKContentView _removeVisibilityPropagationForWebProcess:]):
(-[WKContentView _setupVisibilityPropagationForGPUProcess]):
(-[WKContentView _setupVisibilityPropagationForModelProcess]):
(-[WKContentView _removeVisibilityPropagationViewForGPUProcess]):
(-[WKContentView _removeVisibilityPropagationViewForModelProcess]):
(-[WKContentView _resetVisibilityPropagation]):
(-[WKContentView _createLayerHostingVisibilityPropagator]):
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

Canonical link: https://commits.webkit.org/314516@main
@webkit-commit-queue webkit-commit-queue force-pushed the eng/iOS-Propagate-visibility-during-fullscreen-video-layer-hosting branch from 6895f50 to 23a2f28 Compare June 4, 2026 01:10
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 314516@main (23a2f28): https://commits.webkit.org/314516@main

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

@webkit-commit-queue webkit-commit-queue merged commit 23a2f28 into WebKit:main Jun 4, 2026
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 4, 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.

5 participants