[mythtv-commits] Ticket #12902: Cannot make QOpenGLContext current in a different thread (occurred while watching live tv)

MythTV noreply at mythtv.org
Wed Jan 11 18:48:36 UTC 2017

#12902: Cannot make QOpenGLContext current in a different thread (occurred while
watching live tv)
 Reporter:  William L. DeRieux IV                |          Owner:
  <WilliamDeRieux@…>                             |
     Type:  Bug Report - Crash                   |         Status:  new
 Priority:  critical                             |      Milestone:  0.28.1
Component:  Qt5 issues                           |        Version:  0.28.0
 Severity:  high                                 |     Resolution:
 Keywords:                                       |  Ticket locked:  0

Comment (by WilliamDeRieux@…):

 Replying to [comment:13 stuarta]:
 > Right, we definitely need to resolve this as it's a Qt5 specific issue.
 > It looks like either the fallback de-interlacer or the change speed code
 > is doing the wrong thing. Based on comment#12 i suspect it's the
 > de-interlacer code.

 You said it is related to #comment:12 -- that was actually a link
 #ticket:12 -- and that it is a problem with the fallback de-interlacer

 MythPlayer::ChangeSpeed() will call
 VideoOutput::FallbackDeint() which passes the fallback de-interlacer to
 VideoOutputOpenGL::SetupDeinterlace(bool, QString const&) this function
 then directly calls
 OpenGLLocker::OpenGLLocker(MythRenderOpenGL*) which causes the error
 'Cannot make QOpenGLContext current in a different thread'.

 From that, I guess, the issue occurs when the de-interlacer is setup on a
 thread that does not belong to the QOpenGLContext.

 The faulting line in SetupDeinterlace is this:
 OpenGLLocker ctx_lock(gl_context);

 which calls:
 OpenGLLocker::OpenGLLocker(MythRenderOpenGL *render) : m_render(render)
     if (m_render)

 I suppose that there needs to be some sort of check in the OpenGLLocker
 constructor that

 1) checks if the the call is on the correct thread.


 2) makes a call to m_render->moveToThread(QThread *targetThread)

 This is a quote from the QT 5 Documentation:


 Thread Affinity

 QOpenGLContext can be moved to a different thread with moveToThread(). Do
 call makeCurrent() from a different thread than the one to which the
 QOpenGLContext object belongs. A context can only be current in one thread
 and against one surface at a time, and a thread only has one context
 at a time.

 Also, given the above, I suppose it is actually a problem with QT5 and
 that it has nothing to do with video decoding or anything else.


Ticket URL: <https://code.mythtv.org/trac/ticket/12902#comment:14>
MythTV <http://www.mythtv.org>
MythTV Media Center

More information about the mythtv-commits mailing list