Skip to content

Commit

Permalink
[GStreamer][WebRTC] Deadlocks web process at shutdown
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259973

Reviewed by Carlos Garcia Campos.

When stopping outgoing media sources we were sending an EOS event to the mediastreamsrc, but not to
the fallback source, so the downstream input-selector was blocked forever, waiting the EOS event
from that source.

* Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceGStreamer.cpp:
(WebCore::RealtimeOutgoingAudioSourceGStreamer::stopFallbackSource):
* Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingAudioSourceGStreamer.h:
* Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingMediaSourceGStreamer.cpp:
(WebCore::RealtimeOutgoingMediaSourceGStreamer::stopOutgoingSource):
* Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingMediaSourceGStreamer.h:
(WebCore::RealtimeOutgoingMediaSourceGStreamer::stopFallbackSource):
* Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceGStreamer.cpp:
(WebCore::RealtimeOutgoingVideoSourceGStreamer::stopFallbackSource):
* Source/WebCore/platform/mediastream/gstreamer/RealtimeOutgoingVideoSourceGStreamer.h:

Canonical link: https://commits.webkit.org/266759@main
  • Loading branch information
philn committed Aug 10, 2023
1 parent a36c08c commit e3416ac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class RealtimeOutgoingAudioSourceGStreamer final : public RealtimeOutgoingMediaS
void unlinkOutgoingSource() final;
void linkOutgoingSource() final;

GRefPtr<GstElement> m_fallbackSource;
GRefPtr<GstElement> m_audioconvert;
GRefPtr<GstElement> m_audioresample;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ RealtimeOutgoingMediaSourceGStreamer::RealtimeOutgoingMediaSourceGStreamer(const
m_bin = gst_bin_new(nullptr);

m_inputSelector = gst_element_factory_make("input-selector", nullptr);
gst_util_set_object_arg(G_OBJECT(m_inputSelector.get()), "sync-mode", "clock");

m_preEncoderQueue = gst_element_factory_make("queue", nullptr);
m_postEncoderQueue = gst_element_factory_make("queue", nullptr);
Expand All @@ -70,6 +71,15 @@ RealtimeOutgoingMediaSourceGStreamer::~RealtimeOutgoingMediaSourceGStreamer()
if (m_transceiver)
g_signal_handlers_disconnect_by_data(m_transceiver.get(), this);

if (m_fallbackSource) {
gst_element_set_locked_state(m_fallbackSource.get(), TRUE);
gst_element_set_state(m_fallbackSource.get(), GST_STATE_READY);
gst_element_unlink(m_fallbackSource.get(), m_inputSelector.get());
gst_element_set_state(m_fallbackSource.get(), GST_STATE_NULL);
gst_element_release_request_pad(m_inputSelector.get(), m_fallbackPad.get());
gst_element_set_locked_state(m_fallbackSource.get(), FALSE);
}

stopOutgoingSource();

if (GST_IS_PAD(m_webrtcSinkPad.get())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class RealtimeOutgoingMediaSourceGStreamer : public ThreadSafeRefCounted<Realtim
GRefPtr<GstPad> m_webrtcSinkPad;
RefPtr<UniqueSSRCGenerator> m_ssrcGenerator;
GUniquePtr<GstStructure> m_parameters;
GRefPtr<GstElement> m_fallbackSource;

private:
void sourceMutedChanged();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class RealtimeOutgoingVideoSourceGStreamer final : public RealtimeOutgoingMediaS

void updateStats(GstBuffer*);

GRefPtr<GstElement> m_fallbackSource;
GRefPtr<GstElement> m_videoConvert;
GRefPtr<GstElement> m_videoFlip;
GRefPtr<GstElement> m_videoRate;
Expand Down

0 comments on commit e3416ac

Please sign in to comment.