Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e41237fcf56f9456c9a38994fa0adeab252ddb9b
https://github.com/WebKit/WebKit/commit/e41237fcf56f9456c9a38994fa0adeab252ddb9b
Author: Aditya Keerthi <[email protected]>
Date: 2025-04-15 (Tue, 15 Apr 2025)
Changed paths:
M Source/WebKit/UIProcess/ApplicationStateTracker.h
M Source/WebKit/UIProcess/ApplicationStateTracker.mm
Log Message:
-----------
[Catalyst] visibilitychange event is not always dispatched when closing
windows
https://bugs.webkit.org/show_bug.cgi?id=291433
rdar://148773181
Reviewed by Abrar Rahman Protyasha and Tim Horton.
`visibilitychange` events correspond to the addition or removal of
`ActivityState::IsVisible` from the activity state flags. The flag is
added if `isViewVisible()` returns true. Web views that have a non-nil
`window`, and for which `-[WKWebView _isBackground]` is false, are considered
to be visible.
`-[WKWebView _isBackground]` reports the value of
`ApplicationStateTracker::isInBackground`. When a Catalyst window is closed,
`UISceneDidEnterBackgroundNotification` gets dispatched, which sets
`isInBackground`
to true and schedules an activity state update. Note that the web view's window
remains non-nil.
However, in between `UISceneDidEnterBackgroundNotification` and the activity
state update dispatch, the web view's window's scene may get set to `nil`. This
is problematic due to the changes in 276009@main, which treat a web view with a
non-nil window and nil scene as "foreground". `UINSSceneView` does exactly that
in Catalyst, resulting in the web view being incorrectly reported as visible,
after closing the window.
The change in 276009@main is still necessary to keep API tests passing. Fix by
avoiding an additional update to `isInBackground` when the scene was previously
non-nil. This keeps tests passing as the scene is always nil, and fixes the
issue
as the value set as a result of `UISceneDidEnterBackgroundNotification` is
preserved.
Add additional logging to make application state tracking issues easier to
diagnose.
* Source/WebKit/UIProcess/ApplicationStateTracker.h:
* Source/WebKit/UIProcess/ApplicationStateTracker.mm:
(WebKit::ApplicationStateTracker::setScene):
(WebKit::ApplicationStateTracker::setViewController):
(WebKit::ApplicationStateTracker::setIsInBackground):
Avoid updating `m_isInBackground` if it is already true and the scene is
transitioning from non-nil to nil. This is necessary, as a view that initially
has a window and a nil scene is treated as foreground (visible), due to
276009@main.
(WebKit::ApplicationStateTracker::applicationDidEnterBackground):
(WebKit::ApplicationStateTracker::applicationWillEnterForeground):
Canonical link: https://commits.webkit.org/293743@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes