Skip to content

Commit

Permalink
Merge r226947 - [GStreamer] Don't wait for draw condition variable wh…
Browse files Browse the repository at this point in the history
…en shutting down.

https://bugs.webkit.org/show_bug.cgi?id=180978

Patch by Sebastian Dröge <sebastian@centricular.com> on 2018-01-15
Reviewed by Carlos Garcia Campos.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
(WebCore::MediaPlayerPrivateGStreamerBase::cancelRepaint):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
By also waiting for the draw condition variable while shutting down,
it is possible that the GStreamer video sink is waiting for the main
thread to actually render the current frame, while at the same time
the main thread is waiting for the GStreamer video sink to shut down,
resulting in a deadlock.
  • Loading branch information
sdroege authored and carlosgcampos committed Jan 24, 2018
1 parent eaba652 commit 15f7fa8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
17 changes: 17 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
2018-01-15 Sebastian Dröge <sebastian@centricular.com>

[GStreamer] Don't wait for draw condition variable when shutting down.
https://bugs.webkit.org/show_bug.cgi?id=180978

Reviewed by Carlos Garcia Campos.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::triggerRepaint):
(WebCore::MediaPlayerPrivateGStreamerBase::cancelRepaint):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
By also waiting for the draw condition variable while shutting down,
it is possible that the GStreamer video sink is waiting for the main
thread to actually render the current frame, while at the same time
the main thread is waiting for the GStreamer video sink to shut down,
resulting in a deadlock.

2017-10-06 Enrique Ocaña González <eocanha@igalia.com>

[MSE][GStreamer] Seek on youtube.com/tv fails after r217185
Expand Down
Expand Up @@ -661,6 +661,8 @@ void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample)

if (!m_renderingCanBeAccelerated) {
LockHolder locker(m_drawMutex);
if (m_drawCancelled)
return;
m_drawTimer.startOneShot(0_s);
m_drawCondition.wait(m_drawMutex);
return;
Expand All @@ -672,6 +674,8 @@ void MediaPlayerPrivateGStreamerBase::triggerRepaint(GstSample* sample)
#else
{
LockHolder lock(m_drawMutex);
if (m_drawCancelled)
return;
if (!m_platformLayerProxy->scheduleUpdateOnCompositorThread([this] { this->pushTextureToCompositor(); }))
return;
m_drawCondition.wait(m_drawMutex);
Expand All @@ -687,11 +691,14 @@ void MediaPlayerPrivateGStreamerBase::repaintCallback(MediaPlayerPrivateGStreame

void MediaPlayerPrivateGStreamerBase::cancelRepaint()
{
LockHolder locker(m_drawMutex);

if (!m_renderingCanBeAccelerated) {
m_drawTimer.stop();
LockHolder locker(m_drawMutex);
m_drawCondition.notifyOne();
}

m_drawCancelled = true;
m_drawCondition.notifyOne();
}

void MediaPlayerPrivateGStreamerBase::repaintCancelledCallback(MediaPlayerPrivateGStreamerBase* player)
Expand Down
Expand Up @@ -205,6 +205,7 @@ class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface

Condition m_drawCondition;
Lock m_drawMutex;
bool m_drawCancelled { false };
RunLoop::Timer<MediaPlayerPrivateGStreamerBase> m_drawTimer;

#if USE(TEXTURE_MAPPER_GL)
Expand Down

0 comments on commit 15f7fa8

Please sign in to comment.