Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 640e6ff568d1d8da981d8dc30ac70ba7f20880c4
      
https://github.com/WebKit/WebKit/commit/640e6ff568d1d8da981d8dc30ac70ba7f20880c4
  Author: Eric Carlson <[email protected]>
  Date:   2026-05-05 (Tue, 05 May 2026)

  Changed paths:
    M Source/WebCore/html/HTMLMediaElement.cpp
    M Source/WebCore/html/HTMLMediaElement.h
    M 
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

  Log Message:
  -----------
  ASSERT under HTMLMediaElement::virtualHasPendingActivity
https://bugs.webkit.org/show_bug.cgi?id=314034
rdar://176143872

Reviewed by Jean-Yves Avenard and Ryosuke Niwa.

Many MediaPlayerPrivateMediaSourceAVFObjC member variables are a 
main-thread-only but
it can be access from the worker thread by the MediaSource/Private, so its 
destructor
should always run on the main thread.

While investigation this it was observed that 
HTMLMediaElement::virtualHasPendingActivity
may be called from the GC thread but it calls 
HTMLMediaElement::canProduceAudio() which
calls MediaPlayer::hasAudio() and creates a temporary RefPtr to the 
MediaPlayerPrivate.
This is unnecessary as every MediaPlayer notifies HTMLMediaElement when its 
ability to
produce audio changes, so fix this by caching `canProduceAudio` in a 
std::atomic which is
updated only on the main thread whenever relevant state changes. 
canProduceAudio()
now just returns the cached value and is safe to call from any thread.

* Source/WebCore/html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::canProduceAudio const):
(WebCore::HTMLMediaElement::computeCanProduceAudio const):
(WebCore::HTMLMediaElement::canProduceAudioChanged):
* Source/WebCore/html/HTMLMediaElement.h:
* 
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:

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



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

Reply via email to