[webkit-changes] [WebKit/WebKit] 86489e: [visionOS] Audio in a background tab does not paus...
Jer Noble
noreply at github.com
Mon Mar 11 18:04:41 PDT 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 86489e41e7b65569d848851ea8149a8553c7f3fd
https://github.com/WebKit/WebKit/commit/86489e41e7b65569d848851ea8149a8553c7f3fd
Author: Jer Noble <jer.noble at apple.com>
Date: 2024-03-11 (Mon, 11 Mar 2024)
Changed paths:
M Source/WebKit/UIProcess/ApplicationStateTracker.h
M Source/WebKit/UIProcess/ApplicationStateTracker.mm
M Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm
Log Message:
-----------
[visionOS] Audio in a background tab does not pause when UIWindowScene is backgrounded
https://bugs.webkit.org/show_bug.cgi?id=270683
rdar://123911798
Reviewed by Ben Nham and Chris Dumez.
When a WKWebView is removed from its UIWindow, it destroys its ApplicationStateTracker, which was
observing the view's window's UIWindowScene to detect changes to the scene's foreground/background
state. So unparented WKWebViews with audible media playback are not notified when their former
UIWindowScene is backgrounded; only when the entire application is. This can result in backgrounded
tabs continuing to play when only one scene (and not the entire app) is backgrounded.
Rather than tear down the ApplicationStateTracker when unparented, the WKWebView should leave the
UIWindowScene observer in place, and recreate the tracker when moved to a new window. Additionally,
the UIWindow's windowScene property is dynamic, and clients of WKWebWiew may move the view's window
between UIWindowScenes. Refactor ApplicationStateTracker to have explicit setters for the window,
scene, and viewController being observed, and allow clients to update the window being tracked dynamically.
This handles the case where a WKWebView is removed from a window (the tracker remains, and notifies
the WKWebView when its former UIWindowScene is backgrounded/foregrounded), when the WKWebView is added
to a different window (the tracker is recreated), when the WKWebView's window is moved to a different
scene (the tracker is recreated), and should even handle the currently-impossible scenario of a
WKWebView changing from being hosted in an Application to hosted in a View Service.
* Source/WebKit/UIProcess/ApplicationStateTracker.h:
* Source/WebKit/UIProcess/ApplicationStateTracker.mm:
(WebKit::ApplicationStateTracker::ApplicationStateTracker):
(WebKit::ApplicationStateTracker::~ApplicationStateTracker):
(WebKit::ApplicationStateTracker::setWindow):
(WebKit::ApplicationStateTracker::setScene):
(WebKit::ApplicationStateTracker::setViewController):
* Source/WebKit/UIProcess/ios/WKApplicationStateTrackingView.mm:
(-[WKApplicationStateTrackingView willMoveToWindow:]):
(-[WKApplicationStateTrackingView didMoveToWindow]):
(-[WKApplicationStateTrackingView observeValueForKeyPath:ofObject:change:context:]):
(-[WKApplicationStateTrackingView _willBeginSnapshotSequence]):
(-[WKApplicationStateTrackingView _didCompleteSnapshotSequence]):
Canonical link: https://commits.webkit.org/275943@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