Created attachment 106781 [details] DebugView output Krita: Thread 1: 1 ntdll!ZwDelayExecution 0x779ec07a 2 SleepEx 0x7fefd9e1203 3 QWindowsPipeReader::waitForPipeClosed qwindowspipereader.cpp 356 0x7feacf4b93f 4 QLocalSocket::waitForDisconnected qlocalsocket_win.cpp 408 0x7fe6cb5b285 5 QMic::connected QMic.cpp 297 0x7fe269688b8 ... <More> gmic-krita-qt-2.0.3_pre-win64 (no debug symbols): Thread 1: 1 ntdll!ZwDelayExecution 0x779ec07a 2 SleepEx 0x7fefd9e1203 3 QWindowsPipeReader::waitForNotification(int) 0x66892356 4 QWindowsPipeReader::waitForReadyRead(int) 0x66892435 5 QLocalSocket::waitForReadyRead(int) 0x6d2adaf3 6 ?? 0x40988c 7 ?? 0x40b55d 8 ?? 0x478e86 9 ?? 0x47e321 10 QWidget::event(QEvent *) 0x17bcff8 11 QApplicationPrivate::notify_helper(QObject *, QEvent *) 0x1777f9c 12 QApplication::notify(QObject *, QEvent *) 0x177eefc 13 QCoreApplication::notifyInternal2(QObject *, QEvent *) 0x668cb812 14 QWidgetPrivate::sendPaintEvent(QRegion const&) 0x17b561d ... <More> Judging from the time it takes to call `QLocalSocket::waitForReadyRead` (1 second), the deadlock probably happens here (unless the code has changed after the release): https://github.com/c-koi/gmic-qt/blob/8e4511256c0b420f33252356d4741034044423ae/src/host_krita.cpp#L92 Attached the DebugView output. "QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState " appears rather frequently, it might be related.
An additional note, my Krita is compiled with Qt 5.9.1
Git commit eaa459e3c28951ef3b280271d8f370a848f92e16 by Alvin Wong. Committed on 21/07/2017 at 16:17. Pushed by alvinwong into branch 'krita/3.2'. Do not wait indefinitely for socket in QMic plugin This works around a possible lockups with gmic-qt. Instead of waiting for the socket forever, it should only freeze for a aximum of 8 seconds. M +14 -5 plugins/extensions/qmic/QMic.cpp https://commits.kde.org/krita/eaa459e3c28951ef3b280271d8f370a848f92e16
Git commit 2c9c9cb2709f700d195bd0cfffd939f4a61b69e0 by Alvin Wong. Committed on 21/07/2017 at 16:16. Pushed by alvinwong into branch 'master'. Do not wait indefinitely for socket in QMic plugin This works around a possible lockups with gmic-qt. Instead of waiting for the socket forever, it should only freeze for a aximum of 8 seconds. M +12 -3 plugins/extensions/qmic/QMic.cpp https://commits.kde.org/krita/2c9c9cb2709f700d195bd0cfffd939f4a61b69e0
I made some changes to stop the lockups, but it just hides the actual bug, gmic-qt will sometimes not able to receive the image data properly and cause other errors.
This will appear in DebugView occasionally and gmic-qt will show some error or an empty image (PID 8608 is gmic-qt). [11308] Sending "key_{bb238f3f-6f95-4a63-ae5b-5c5e60fb4c0c},4c61796572203136,3600,2400\n" [11308] Failed to write response: QLocalSocket::UnknownSocketError [11308] Remote not disconnected: QLocalSocket::UnknownSocketError [11308] QLocalSocket::waitForDisconnected() is not allowed in UnconnectedState [8608] Stale request [8608] gmic-qt: empty answer! [8608] QImage::scaled: Image is a null image Look for "Failed to write response" and "Stale request". I was not able to reproduce this at all with 3.2.0 beta 2 (which uses Qt 5.6.1).
Created attachment 106940 [details] Test program for testing QLocalSocket communication
Created attachment 106941 [details] Test program for testing QLocalSocket communication (qmake file)
Here are several commits in Qt that *might* be related to the issue? But I haven't tested reverting them. QLocalSocket/Win: use QRingBuffer::append https://github.com/qt/qtbase/commit/1675d9a1b23794592a55746dfebd6f40478fde03 QLocalSocket/Win: Use QIODevice's internal write buffer https://github.com/qt/qtbase/commit/082ee835b0e09f77e0e1bd061323a1b70178d202 QLocalSocket/Win: Fix access to deleted pipeWriter https://github.com/qt/qtbase/commit/4d7313a466dd775e58705924f72525d4838c70fe
Tracing with gdb, it seems to be that whenever it failed to send the data, it's QDataStream::writeBytes returning on qtbase\src\corelib\io\qdatastream.cpp:1348 1348 CHECK_STREAM_WRITE_PRECOND(*this) But upon inspection, QDataStream::dev is not null, which means it shouldn't have returned. Now I'm rather confused.
Git commit a0eef62be22fe6e30293a840fd3cb580fe79772f by Alvin Wong. Committed on 30/07/2017 at 10:49. Pushed by alvinwong into branch 'master'. Work around possible gmic-qt write issues with Qt 5.7+ M +5 -0 plugins/extensions/qmic/QMic.cpp https://commits.kde.org/krita/a0eef62be22fe6e30293a840fd3cb580fe79772f
Worked around, so I'll call this fixed. Delaying the real "fix" until someone decide to improve on the IPC code in the Qmic plugin...