Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 19e19acf45b561b9492ed324aa0b55729dda5cba
      
https://github.com/WebKit/WebKit/commit/19e19acf45b561b9492ed324aa0b55729dda5cba
  Author: Andy Estes <[email protected]>
  Date:   2026-06-05 (Fri, 05 Jun 2026)

  Changed paths:
    A 
LayoutTests/media/video-invisible-audible-autoplay-not-allowed-expected.txt
    A LayoutTests/media/video-invisible-audible-autoplay-not-allowed.html
    A LayoutTests/media/video-invisible-audible-playback-continues-expected.txt
    A LayoutTests/media/video-invisible-audible-playback-continues.html
    M LayoutTests/platform/mac-wk2/TestExpectations
    M Source/WebCore/html/HTMLMediaElement.h
    M Source/WebCore/html/MediaElementSession.cpp

  Log Message:
  -----------
  REGRESSION(311380@main): [macOS wk2 ] 
media/video-concurrent-visible-playback.html is a flaky TEXT failure
https://bugs.webkit.org/show_bug.cgi?id=315354
rdar://177711185

Reviewed by Eric Carlson and Jer Noble.

MediaElementSession::autoplayPermitted() allowed an audible-but-invisible video 
to autoplay even
when the InvisibleAutoplayNotPermitted restriction is set, on the grounds that 
pausing audible
playback would be observable to the user. This bypass was applied 
unconditionally, including for
elements that had not yet started playing. After 311380@main added an 
IntersectionObserver-driven
path (LazyLoadVideoObserver) that called updateShouldAutoplay() more eagerly, 
this caused
audible-but-paused <video autoplay> elements to begin playing while invisible if
autoplayPermitted() happened to be evaluated after metadata had loaded (so that 
hasAudio() returned
true) but before any earlier evaluation had set up the InvisibleAutoplay 
interruption.

While 311380@main made this test noticeably flakier, the underlying problem 
where invisible,
audible elements were allowed to begin playing predates that change (that bug 
was introduced in
r215120).

Resolved this by gating the audio bypass on !element->paused() so that it only 
preserves playback
for videos that are already playing audibly. Paused elements fall through to 
the existing
renderer-visibility checks and are correctly blocked from autoplaying while 
invisible.

Un-skipped media/video-concurrent-visible-playback.html, and added two layout 
tests to verify that:
- invisible, audible videos do not start autoplaying
- audible videos continue playing once no longer visible

* LayoutTests/media/video-invisible-audible-autoplay-not-allowed-expected.txt: 
Added.
* LayoutTests/media/video-invisible-audible-autoplay-not-allowed.html: Added.
* LayoutTests/media/video-invisible-audible-playback-continues-expected.txt: 
Added.
* LayoutTests/media/video-invisible-audible-playback-continues.html: Added.
* LayoutTests/platform/mac-wk2/TestExpectations:
* Source/WebCore/html/HTMLMediaElement.h:
(WebCore::HTMLMediaElement::wasInterruptedForInvisibleAutoplay const):
* Source/WebCore/html/MediaElementSession.cpp:
(WebCore::autoplayPermittedWhileInvisible):
(WebCore::MediaElementSession::autoplayPermitted const):

Canonical link: https://commits.webkit.org/314638@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to