Skip to content

Commit

Permalink
[GStreamer] imported/w3c/web-platform-tests/webaudio/the-audio-api/th…
Browse files Browse the repository at this point in the history
…e-audioworklet-interface/audioworkletprocessor-promises.https.html is flaky crash

https://bugs.webkit.org/show_bug.cgi?id=268541
<rdar://problem/122117396>

Reviewed by Xabier Rodriguez-Calvar.

The crash backtrace suggested the WebAudioSource element was attempting to use a dangling pointer.
Ideally we should make the AudioDestination a weak pointer in the WebAudioSource but that breaks
assumptions elsewhere where AudioDestination is used as a RefCounted.

* Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
(WebCore::AudioDestinationGStreamer::~AudioDestinationGStreamer):
* Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
(webkit_web_audio_src_class_init):
(webKitWebAudioSrcConstructed):
(webKitWebAudioSrcRenderAndPushFrames):

Canonical link: https://commits.webkit.org/274202@main
  • Loading branch information
philn committed Feb 7, 2024
1 parent da96990 commit ca5c43b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ AudioDestinationGStreamer::AudioDestinationGStreamer(AudioIOCallback& callback,
AudioDestinationGStreamer::~AudioDestinationGStreamer()
{
GST_DEBUG_OBJECT(m_pipeline.get(), "Disposing");
if (LIKELY(m_src))
g_object_set(m_src.get(), "destination", nullptr, nullptr);
unregisterPipeline(m_pipeline);
disconnectSimpleBusMessageCallback(m_pipeline.get());
gst_element_set_state(m_pipeline.get(), GST_STATE_NULL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ static void webkit_web_audio_src_class_init(WebKitWebAudioSrcClass* webKitWebAud
G_MINDOUBLE, G_MAXDOUBLE,
44100.0, flags));

g_object_class_install_property(objectClass, PROP_DESTINATION, g_param_spec_pointer("destination", "destination",
"Destination", flags));
g_object_class_install_property(objectClass, PROP_DESTINATION, g_param_spec_pointer("destination", "destination", "Destination", G_PARAM_READWRITE));

g_object_class_install_property(objectClass,
PROP_FRAMES,
Expand All @@ -204,7 +203,6 @@ static void webKitWebAudioSrcConstructed(GObject* object)
WebKitWebAudioSrc* src = WEBKIT_WEB_AUDIO_SRC(object);
WebKitWebAudioSrcPrivate* priv = src->priv;

ASSERT(priv->destination);
ASSERT(priv->sampleRate);

GST_OBJECT_FLAG_SET(GST_OBJECT_CAST(src), GST_ELEMENT_FLAG_SOURCE);
Expand Down Expand Up @@ -316,6 +314,9 @@ static void webKitWebAudioSrcRenderAndPushFrames(const GRefPtr<GstElement>& elem
priv->dispatchCondition.notifyOne();
});

if (!priv->destination)
return;

GST_TRACE_OBJECT(element.get(), "Playing: %d", priv->destination->isPlaying());
if (priv->hasRenderedAudibleFrame && !priv->destination->isPlaying())
return;
Expand Down

0 comments on commit ca5c43b

Please sign in to comment.