Skip to content

Commit

Permalink
[MSE] Intermittent crash with imported/w3c/web-platform-tests/media-s…
Browse files Browse the repository at this point in the history
…ource/URL-createObjectURL-null.html

https://bugs.webkit.org/show_bug.cgi?id=269656
rdar://123171059

Reviewed by Chris Dumez.

`MediaSource::ensureWeakOnHTMLMediaElementContext` took a strong ref to the HTMLMediaElement but this code can be called while the HTMLMediaElement is being destructed.

`ASSERT(!deletionHasBegun());`

We use a RefPtrAllowingPartiallyDestroyed instead which avoid the problem for now.

Ideally the logic should be refactored to avoid calling the method in the first place
if the HTMLMediaElement has gone away.

* Source/WebCore/Modules/mediasource/MediaSource.cpp:
(WebCore::MediaSource::ensureWeakOnHTMLMediaElementContext const):

Canonical link: https://commits.webkit.org/274942@main
  • Loading branch information
jyavenard committed Feb 18, 2024
1 parent 37058f4 commit a691187
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Source/WebCore/Modules/mediasource/MediaSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,12 +1337,11 @@ void MediaSource::notifyElementUpdateMediaState() const
void MediaSource::ensureWeakOnHTMLMediaElementContext(Function<void(HTMLMediaElement&)>&& task) const
{
ensureOnMainThread([weakMediaElement = m_mediaElement, task = WTFMove(task)]() mutable {
if (RefPtr mediaElement = weakMediaElement.get())
if (RefPtrAllowingPartiallyDestroyed<HTMLMediaElement> mediaElement = weakMediaElement.get())
task(*mediaElement);
});
}


void MediaSource::sourceBufferBufferedChanged()
{
updateBufferedIfNeeded();
Expand Down

0 comments on commit a691187

Please sign in to comment.