Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: ac6cdc15d34672c3d00c9e4a0dcdba767a19ca25
https://github.com/WebKit/WebKit/commit/ac6cdc15d34672c3d00c9e4a0dcdba767a19ca25
Author: Jer Noble <[email protected]>
Date: 2026-03-23 (Mon, 23 Mar 2026)
Changed paths:
M Source/WebCore/html/HTMLMediaElement.cpp
M Source/WebCore/html/HTMLMediaElement.h
M Source/WebCore/html/MediaElementSession.cpp
M Source/WebCore/html/MediaElementSession.h
M Source/WebCore/platform/LogMessages.in
M Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm
Log Message:
-----------
Logging causes excessive CPU usage on Wikimedia page
rdar://173108312
https://bugs.webkit.org/show_bug.cgi?id=310482
Reviewed by Jean-Yves Avenard.
Logging from inside HTMLMediaElement::canTransitionFromAutoplayToPlay() and
MediaElementSession::playbackStateChangePermitted() overwhelm the main thread of
the WebContent process when many video elements are loaded simultaneously, on
such
pages as Wikimedia category pages. These methods are called in tight loops from
other methods which calculate the "most appropriate element" for various
purposes.
Move the logging from inside these methods to their callers, where the logging
can
happen only when appropriate, such as when an individual media element tries to
play or pause, and not when called as a side effect of a state calculation.
To do so, those two methods now return an Expected<void, ...>, the error object
of which contains both a reason the call failed, as well as a text description.
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::canTransitionFromAutoplayToPlay const):
(WebCore::HTMLMediaElement::setReadyState):
(WebCore::HTMLMediaElement::play):
(WebCore::HTMLMediaElement::resumeAutoplaying):
(WebCore::HTMLMediaElement::updateShouldPlay):
(WebCore::HTMLMediaElement::mediaStreamCaptureStarted):
* Source/WebCore/html/HTMLMediaElement.h:
* Source/WebCore/html/MediaElementSession.cpp:
(WebCore::MediaElementSession::playbackStateChangePermitted const):
(WebCore::convertEnumerationToString):
* Source/WebCore/html/MediaElementSession.h:
(WTF::LogArgument<WebCore::MediaPlaybackDenialExplanation>::toString):
* Source/WebCore/platform/LogMessages.in:
* Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm:
(WebCore::MediaSessionManagerCocoa::clientCharacteristicsChanged):
Canonical link: https://commits.webkit.org/309763@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications