Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 05aab377dd33755b8a6c34c3c53a275f5daaed83
      
https://github.com/WebKit/WebKit/commit/05aab377dd33755b8a6c34c3c53a275f5daaed83
  Author: Jean-Yves Avenard <[email protected]>
  Date:   2026-07-24 (Fri, 24 Jul 2026)

  Changed paths:
    M Source/WebCore/html/HTMLMediaElement.cpp
    M Source/WebCore/html/HTMLMediaElement.h

  Log Message:
  -----------
  [site-isolation] media/media-play-promise-reject-pause-abort.html is a 
permanent timeout
https://bugs.webkit.org/show_bug.cgi?id=320173
rdar://183108599

Reviewed by Eric Carlson.

play(); pause(); play(); sequence could leave play() promise permanently 
unsettled.

play() sent an admission request to the media session (clientWillBeginPlayback)
and settled the pending play promises from its plain CompletionHandler, guarded
by a bool flag (m_canBeginPlaybackInFlight) so a same-tick pause() wouldn't
reject them out from under it. That flag only suppressed the reject call; it
did nothing to cancel the in-flight admission itself. If pause() ran while
admission was pending, clientWillBeginPlayback's own race handling would still
resolve canBegin true, but with the paused/no-readyState booleans captured at
play() time now stale, the completion handler settled nothing and the play()
promise hung forever under Site Isolation's async admission path.

Replaced the flag with a NativePromiseRequest (m_playRequest) that tracks the
in-flight admission as a cancellable GenericPromise. pauseInternal() now
disconnects m_playRequest before touching m_paused, so a pause() during
admission cancels the stale continuation outright instead of just muting one
side effect of it, and the plain !m_paused guard reliably rejects the pending
promises. Also handles play() called again on an already-playing element
getting denied on re-admission, situation which the old flag didn't cover
either.

Made the disconnect/reject conditional on a new 
m_playPromiseSettlementGuaranteed
flag, captured alongside shouldNotifyAboutPlaying/shouldResolvePromises: when
either of those was already true at play() time, the admission's own completion
handler is guaranteed to settle the promise itself, so pauseInternal() must
leave it alone instead of preempting it with a spurious AbortError.

Covered by existing test.

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::~HTMLMediaElement):
(WebCore::HTMLMediaElement::playInternal):
(WebCore::HTMLMediaElement::pauseInternal):
* Source/WebCore/html/HTMLMediaElement.h:

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



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

Reply via email to