moonlight-stream / moonlight-qt

GameStream client for PCs (Windows, Mac, Linux, and Steam Link)
GNU General Public License v3.0
10.47k stars 614 forks source link

Crash while starting stream if I move the mouse out of the window #1019

Open sgtnoodle opened 1 year ago

sgtnoodle commented 1 year ago

Describe the bug When I click to start a stream, i.e. "DESKTOP", then patiently wait, the stream comes up and is fine. If I instead click "DESKTOP" then immediately move my mouse cursor out from the bounds of the window, moonlight exits with code 1.

Steps to reproduce Click a computer, then click "DESKTOP" (assuming default configuredsunlight server)

Within half a second second, move the mouse cursor to somewhere on the desktop, out of the bounds of the Moonlight window.

It's a relatively short time window. After a second, the stream loads.

Screenshots

Affected games Desktop

Other Moonlight clients

Moonlight settings (please complete the following information)

Gamepad-related issues (please complete if problem is gamepad-related)

Client PC details (please complete the following information)

Server PC details (please complete the following information)

Moonlight Logs (please attach)

...
00:01:30 - SDL Info (0): FFmpeg-based video decoder chosen
00:01:33 - SDL Info (0): Desired audio buffer: 480 samples (1920 bytes)
00:01:33 - SDL Info (0): Obtained audio buffer: 480 samples (1920 bytes)
00:01:35 - Qt Info: Found "gamecontrollerdb.txt" at "/home/jbrogers/.cache/Moonlight Game Streaming Project/Moonlight/gamecontrollerdb.txt"
00:01:35 - SDL Info (0): Loaded 262 new gamepad mappings
00:01:35 - SDL Info (0): V-sync disabled
[jbrogers@zen ~]$ echo $?
1

Additional context Anything else you think may be relevant to the issue

cgutman commented 1 year ago

Are you using the Snap, Flatpak, or AppImage version of Moonlight?

sgtnoodle commented 1 year ago

I believe I installed it from the Arch User Repository, so I'm not really sure. I also manually cloned the master branch and compiled it myself last week, and the bug still exists. I suppose it's possible that I've been using the master branch the whole time. I noticed that the one I compiled still reports itself as 4.3.1. The mouse handling code has clearly been rewritten between the 4.3.1 tag and master. So, maybe this is a recent regression rather than a bug in 4.3.1. It would be nice if --version had a git sha or "dirty" tag if it wasn't a tagged release build.

I'll make sure to try the actual 4.3.1 release tomorrow. Either way, it seems like a bug. Poking around the code, it looks like there's some function calls (there are the words suspend and resume) that are triggered on mouse events when the cursor leaves the bounds of the window. I'm assuming it's a race condition where the session isn't initialized enough for those function calls to work yet.

sgtnoodle commented 1 year ago

I built the 4.3.1 tag locally and it crashes still. I tried the AppImage version, and it seems to not crash. So maybe it has to do with a library version or something? I believe I compiled it with qt6.

cgutman commented 1 year ago

I doubt it's related to our mouse handling, because that doesn't become active until we enter the SDL event loop which is after the stream is established. I suspect Qt 6 is the culprit.

Can you run it under gdb and get a stack trace of the crash?

tsuicaaa commented 3 months ago

The same thing is happening to me too under Fedora 40. The flatpak, Appimage, they all crash when moving the mouse after clicking the "Play" button.

Here's the gdb output:

#1  0x00007ffff558820c in QOpenGLContext::currentContext() () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Gui.so.5
#2  0x00007ffff33d14ed in QSGPlainTexture::bind() () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#3  0x00007ffff33d3e04 in QSGOpaqueTextureMaterialShader::updateState(QSGMaterialShader::RenderState const&, QSGMaterial*, QSGMaterial*) ()
   from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#4  0x00007ffff33b7239 in QSGBatchRenderer::Renderer::renderMergedBatch(QSGBatchRenderer::Batch const*) ()
   from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#5  0x00007ffff33bcfc5 in QSGBatchRenderer::Renderer::renderBatches() () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#6  0x00007ffff33bd51a in QSGBatchRenderer::Renderer::render() () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#7  0x00007ffff33a13e4 in QSGRenderer::renderScene(QSGBindable const&) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#8  0x00007ffff33a18b3 in QSGRenderer::renderScene(unsigned int) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#9  0x00007ffff3410327 in QSGDefaultRenderContext::renderNextFrame(QSGRenderer*, unsigned int) ()
   from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#10 0x00007ffff347dd79 in QQuickWindowPrivate::renderSceneGraph(QSize const&, QSize const&) ()
   from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#11 0x00007ffff33fba44 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#12 0x00007ffff348c2e7 in QQuickWindow::event(QEvent*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#13 0x00007ffff4ac492a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#14 0x00007ffff5535d84 in QPlatformWindow::windowEvent(QEvent*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Gui.so.5
#15 0x00007ffff5542007 in QGuiApplication::notify(QObject*, QEvent*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Gui.so.5
#16 0x00007ffff4ac492a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#17 0x00007ffff4b1e540 in QTimerInfoList::activateTimers() () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#18 0x00007ffff4b1ee2c in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#19 0x00007ffff311e17d in g_main_context_dispatch () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libglib-2.0.so.0
#20 0x00007ffff311e400 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libglib-2.0.so.0
#21 0x00007ffff311e4a3 in g_main_context_iteration () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libglib-2.0.so.0
#22 0x00007ffff4b1f261 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
   from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#23 0x00005555555d986f in Session::exec (this=0x55555656de40, qtWindow=<optimized out>) at /opt/qt515/include/QtCore/qflags.h:121
#24 0x00005555556074cb in Session::qt_static_metacall (_o=_o@entry=0x55555656de40, _c=_c@entry=QMetaObject::InvokeMetaMethod, _id=_id@entry=8, 
    _a=_a@entry=0x7fffffffb990) at release/moc_session.cpp:120
#25 0x0000555555607a43 in Session::qt_metacall (this=0x55555656de40, _c=QMetaObject::InvokeMetaMethod, _id=8, _a=0x7fffffffb990)
    at release/moc_session.cpp:225
#26 0x00007ffff50f2b95 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#27 0x00007ffff4fbb205 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#28 0x00007ffff4fbd307 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
--Type <RET> for more, q to quit, c to continue without paging--
#29 0x00007ffff4fbe1fa in QV4::QObjectMethod::callInternal(QV4::Value const*, QV4::Value const*, int) const ()
   from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#30 0x00007ffff4fddc91 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#31 0x00007ffff4fdfbef in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#32 0x00007ffff4f6cc9d in QV4::Function::call(QV4::Value const*, QV4::Value const*, int, QV4::ExecutionContext const*) ()
   from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#33 0x00007ffff5113027 in QQmlJavaScriptExpression::evaluate(QV4::CallData*, bool*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#34 0x00007ffff50b68de in QQmlBoundSignalExpression::evaluate(void**) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#35 0x00007ffff50b7978 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#36 0x00007ffff50f25fd in QQmlNotifier::emitNotify(QQmlNotifierEndpoint*, void**) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#37 0x00007ffff5094caf in QQmlData::signalEmitted(QAbstractDeclarativeData*, QObject*, int, void**) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#38 0x00007ffff4afb545 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#39 0x00007ffff34e5e16 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#40 0x00007ffff50b0035 in QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt&) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#41 0x00007ffff50b0662 in QQmlIncubationController::incubateFor(int) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Qml.so.5
#42 0x00007ffff348d22b in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Quick.so.5
#43 0x00007ffff4af2435 in QObject::event(QEvent*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#44 0x00007ffff4ac492a in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#45 0x00007ffff4b1e540 in QTimerInfoList::activateTimers() () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#46 0x00007ffff4b1ee74 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#47 0x00007ffff311e17d in g_main_context_dispatch () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libglib-2.0.so.0
#48 0x00007ffff311e400 in ?? () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libglib-2.0.so.0
#49 0x00007ffff311e4a3 in g_main_context_iteration () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libglib-2.0.so.0
#50 0x00007ffff4b1f1f2 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#51 0x00007ffff4ac342b in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#52 0x00007ffff4acb5e4 in QCoreApplication::exec() () from /tmp/.mount_Moonlisi1jGQ/usr/bin/../lib/libQt5Core.so.5
#53 0x0000555555583428 in main (argc=<optimized out>, argv=<optimized out>) at /home/appveyor/projects/moonlight-qt/app/main.cpp:787

EDIT: If the mouse is not moved until the "RTSP handshake" part, it works fine.