Modify
Warning Please read the Ticket HowTo before creating or commenting on a ticket. Failure to do so may cause your ticket to be rejected or result in a slower response.

Opened 2 years ago

Closed 23 months ago

Last modified 23 months ago

#10740 closed Patch - Bug Fix (Fixed)

[PATCH] libmythui: Fix an assert failure in Qt when playing a video

Reported by: Lawrence Rust <lvr@…> Owned by: stichnot
Priority: minor Milestone: 0.25.1
Component: MythTV - Video Playback Version: 0.25-fixes
Severity: medium Keywords: DVD assert
Cc: Ticket locked: no

Description

Trying to play a DVD with a debug build of the Qt library results in
this assertion failure:
ASSERT failure in QCoreApplication::sendEvent: "Cannot send events to objects owned by a different thread. Current thread a8625e78. Receiver 'aa_OSD_SUBTITLES' (of type 'MythScreenType?') was created in thread 9890750", file kernel/qcoreapplication.cpp, line 349

Backtrace & patch attached

Attachments (2)

video-backtrace.txt (4.5 KB) - added by Lawrence Rust <lvr@…> 2 years ago.
0001-libmythui-Fix-an-assert-failure-in-Qt-when-playing-a.patch (1.2 KB) - added by Lawrence Rust <lvr@…> 2 years ago.

Download all attachments as: .zip

Change History (9)

Changed 2 years ago by Lawrence Rust <lvr@…>

Changed 2 years ago by Lawrence Rust <lvr@…>

comment:1 Changed 23 months ago by danielk

  • Component changed from MythTV - Video Playback to MythTV - Captions
  • Owner set to stichnot
  • Status changed from new to assigned

comment:2 Changed 23 months ago by danielk

Jim, this is a real issue but Lawrence's patch fixes a side effect and not the root cause. The problem is that MythUI objects need to be owned by and for the most part interacted with only in the main UI thread.

In this case the objects are probably created in the decoder thread. They either need to be created in the UI thread or re-parented to the UI thread when the decoder passes them along to the UI thread for rendering. Using deleteLater() here might just trade an ASSERT for a memory leak, if the thread that created the objects isn't running a Qt event loop.

comment:3 Changed 23 months ago by stichnot

  • Milestone changed from unknown to 0.25.1
  • Status changed from assigned to accepted

In this case, the MythUI objects are actually created in the UI thread, but the decoder is trying to clear/delete them. This makes me realize there is a race condition here that needs to be addressed in the SubtitleScreen? class, which as a side effect will let us avoid the more invasive change to MythUIType.

comment:4 Changed 23 months ago by Jim Stichnoth <jstichnoth@…>

In f0f37a55d67ffffa27d51ebc6b2cb48589c820fc/mythtv:

Subtitles: Avoid changing subtitle state in the decoder thread.

Use the proper API to defer subtitle changes to the UI event loop, to
avoid creating or deleting MythUI objects in a non-UI thread.
Refs #10740

comment:5 Changed 23 months ago by Jim Stichnoth <jstichnoth@…>

In b695979eb834dfc64b31b8273424104e1e2d48d9/mythtv:

Subtitles: Avoid changing subtitle state in the decoder thread.

Use the proper API to defer subtitle changes to the UI event loop, to
avoid creating or deleting MythUI objects in a non-UI thread.
Refs #10740
(cherry picked from commit f0f37a55d67ffffa27d51ebc6b2cb48589c820fc)

comment:6 Changed 23 months ago by stichnot

  • Component changed from MythTV - Captions to MythTV - Video Playback
  • Resolution set to Fixed
  • Status changed from accepted to closed

Lawrence, I believe this should be fixed, but I don't have a good way to test it, so I'd appreciate it if you could retest and reopen the ticket if you see the same problem.

Fundamentally, this turned out to be a video playback problem, rather than MythUI or captions.

comment:7 Changed 23 months ago by Lawrence Rust <lvr@…>

Confirm fixed in commit b695979.

NB I would strongly recommend testing with a debug build of Qt (and many of the other libraries used by Myth) as they check & report warnings and errors for many API calls. It's very easy to build MythTV with a debug Qt by using my mythbuild.sh script from mythpackaging or here: http://www.softsystem.co.uk/download/mythtv/mythbuild.sh. Once you've got the script then run it:

mythbuild.sh -H -d -b master

-H :build for the host (default is xcompile to win32)
-d : Debug build
-b : Select mythtv branch

It will automatically download all the lib sources required.

If you want to use an existing mythtv git repo then cd to the parent of the repo and mv or ln -s the repo to mythtv and run mythbuild.sh from that directory - it will use the currently checked out branch.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'new'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.