[Development] QML profiling/debugging and threads

Ulf Hermann ulf.hermann at digia.com
Mon Jan 20 12:36:00 CET 2014


Hello,

the attached example will run fine when started standalone, but will 
fail with an assertion

ASSERT: "QThread::currentThread() == 
QCoreApplication::instance()->thread()" in file 
/home/ulf/dev/qt5-src/qtdeclarative/src/qml/debugger/qqmldebugserver.cpp, line 
551 
</home/ulf/dev/qt5-src/qtdeclarative/src/qml/debugger/qqmldebugserver.cpp,%20line%20551>


when trying to debug or profile it. Is that a feature or a bug? I'm 
asking because I'm wondering when to initialize the QML profiler in the 
case of multiple QML engines running in parallel. If this assertion 
didn't exist, when profiling or debugging the example we'd run into 
various problems with the code in QQmlEnginePrivate::init(). 
QQmlEnginePrivate::init() only initializes the various debuggers and 
profilers if it's running in QCoreApplication::instance()->thread().


The test failures I got with 
https://codereview.qt-project.org/#change,75738 show that a whole 
profiling session can be started and finished before the QML engine is 
initialized. Thus I suspect you can even somehow get around that 
assertion above and crash with a segfault from some debugger or profiler 
by delaying the start of the main QML engine and starting another one in 
parallel in the mean time.


I think we should either properly support this case by initializing the 
debuggers and profilers no matter from which thread (which requires them 
all to be thread-safe), or we should handle that more gracefully and not 
just throw an assertion.


regards,

-- 
Ulf Hermann, Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja
Registergericht: Amtsgericht Charlottenburg, HRB 144331 B,

Digia Germany is a group company of Digia Plc,
Valimotie 21, FI-00380 Helsinki Finland

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140120/9a0f81de/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: threadedprofiling.tar.gz
Type: application/x-gzip
Size: 1083 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140120/9a0f81de/attachment.bin>


More information about the Development mailing list