Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 749fddf048e05e5090b6a3120911ff4a439cb801
https://github.com/WebKit/WebKit/commit/749fddf048e05e5090b6a3120911ff4a439cb801
Author: Brent Fulgham <[email protected]>
Date: 2026-05-12 (Tue, 12 May 2026)
Changed paths:
M Source/WebKit/UIProcess/Media/cocoa/MediaUsageManagerCocoa.mm
M Source/WebKit/UIProcess/WebPageProxy.cpp
Log Message:
-----------
MediaUsageManagerCocoa::removeMediaSession doesn't clear UsageTrackingAgent
state when being released
https://bugs.webkit.org/show_bug.cgi?id=314593
rdar://176832251
Reviewed by Ben Nham.
While investigating spurious no-crash-log WebKitTestRunner crashes, I noticed
that we
were periodically being terminated by the kernel for exceeding the process
limit of 2048
kqworkloops. This was happening because we only call `-stop` on playing media
sessions,
which allows any stopped sessions to leak their UsageTrackingAgent connections.
This can happen when a media element is playing, and the page (or test case)
navigates
away. removeMediaSession gets called by the MediaElementSession's destructor
and clears
its collection of media sessions without ensuring any active usageTrackers are
stopped.
This may happen when a page navigates and the "pause" message is not received
in the
UIProcess side before the page teardown begins.
After further testing showed that calling 'stop' was insufficent to close the
XPC connections,
I reviewed ScreenTime's use of this API. This revealed that we always need to
nil out
the usageTracker object after calling stop on it to ensure the XPC connection
is closed.
* Source/WebKit/UIProcess/Media/cocoa/MediaUsageManagerCocoa.mm:
(WebKit::MediaUsageManagerCocoa::reset): Always nil out the usageTracker after
stopping.
(WebKit::MediaUsageManagerCocoa::removeMediaSession): Check the session being
removed for
an active usageTracker member, and call `stop` when one exists, and nil the
object after
calling stop.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCommitLoadForFrame): Add m_mediaUsageManager->reset()
on main
frame navigation. This missing call was causing media sessions to accumulate
across test
iterations.
Canonical link: https://commits.webkit.org/313125@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications