Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 82cb946ab2b3638c6f69793bf2d6c20e4a7a085e
https://github.com/WebKit/WebKit/commit/82cb946ab2b3638c6f69793bf2d6c20e4a7a085e
Author: Ahmad Saleem <[email protected]>
Date: 2026-03-06 (Fri, 06 Mar 2026)
Changed paths:
M
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay-with-slow-text-tracks-expected.txt
M Source/WebCore/html/HTMLMediaElement.cpp
Log Message:
-----------
Autoplay should not proceed before default text tracks finish loading
https://bugs.webkit.org/show_bug.cgi?id=309149
rdar://171699293
Reviewed by Eric Carlson.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
The HTML spec (4.8.11.7 Ready states [1]) defines HAVE_FUTURE_DATA as
requiring that "the text tracks are ready". A media element should
therefore not reach HAVE_FUTURE_DATA (or HAVE_ENOUGH_DATA) and should
not autoplay until all text tracks whose mode was not Disabled when
resource selection began have a readiness state of Loaded or
FailedToLoad.
There is a race between the resource selection task (which captures
m_textTracksWhenResourceSelectionBegan) and the configureTextTracks
task (which sets default tracks to Showing). Because both are queued
tasks, resource selection runs first and sees the default track's mode
as Disabled, so it is never added to the pending list.
textTracksAreReady() then returns true vacuously and autoplay begins
before the VTT file loads.
Fix this by adding tracks to m_textTracksWhenResourceSelectionBegan in
textTrackModeChanged when their mode transitions from Disabled to
Showing/Hidden, but only while the ready state has not yet reached
HAVE_FUTURE_DATA. This ensures textTracksAreReady() blocks ready state
advancement until the track finishes loading, without causing a
readyState regression when a track is enabled after the media has
already fully loaded (which would otherwise re-fire canplaythrough).
[1] https://html.spec.whatwg.org/#dom-media-have_future_data
* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::textTrackModeChanged):
*
LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay-with-slow-text-tracks-expected.txt:
Progression
Canonical link: https://commits.webkit.org/308796@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications