NVIDIA / egl-wayland

The EGLStream-based Wayland external platform
MIT License
275 stars 43 forks source link

Plasma wayland with offloading on intel uhd + nvidia causes freezes of widgets #101

Closed Dvergatal closed 2 months ago

Dvergatal commented 5 months ago

Hi all, I'm experiencing strange desktop behavior when setting prime offloading on wayland with plasma.

Generally my video configuration looks like below:

00:02.0 VGA compatible controller: Intel Corporation Raptor Lake-P [UHD Graphics] (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation AD107M [GeForce RTX 4060 Max-Q / Mobile] (rev a1)

I have built mesa with intel support to use newest modesetting driver which is showing for me in qdbus org.kde.KWin /KWin org.kde.KWin.showDebugConsole as:

OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) Graphics (RPL-P)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 23.3.3
OpenGL core profile shading language version string: 4.60

I don't have any setting for X server, it does it on its own and what I did is just setting of:

__NV_PRIME_RENDER_OFFLOAD=1
__GLX_VENDOR_LIBRARY_NAME=nvidia

in /etc/environment file for offloading streams games etc. into the dGPU. Now the issue I'm is that after some period of time I'm getting some plasma widgets freeze which looks like these: Screenshot_20240117_163512 were highlighting has frozen on both apps and is no longer working, even new apps are not showing in task bar Screenshot_20240117_163540 and in this case time has frozen by the time i'm writting this post it is already 16:52.

All this you can see on this Screenshot_20240117_165353 screenshot and compare clocks between displays. In addition there is another issue, meaning when I'll go with mouse cursor on app thumbnail I should see application's preview but instead I'm seeing a black window...

The only solution for me is to disable this offloading and work with intel modesetting driver instead and than everything works fine.

Dvergatal commented 5 months ago

OK for the widget freeze it occurs that there is a bug already reported on kde with a fix https://bugs.kde.org/show_bug.cgi?id=469016 but for the black screens in thumbnails preview I still dunno what it is...

But in addition I can mention that I'm getting these errors in logs:

sty 18 07:49:15 latitude plasmashell[97241]: [97241:97275:0118/074915.945361:ERROR:gl_context_egl.cc(259)] eglCreateContext failed with error EGL_BAD_CONTEXT
sty 18 07:49:15 latitude plasmashell[97241]: [97241:97275:0118/074915.945363:ERROR:gpu_channel_manager.cc(753)] ContextResult::kFatalFailure: Failed to create shared context for virtualization.
sty 18 07:49:15 latitude plasmashell[97241]: [97241:97275:0118/074915.945365:ERROR:shared_image_stub.cc(470)] SharedImageStub: unable to create context
sty 18 07:49:15 latitude plasmashell[97241]: [97241:97275:0118/074915.945366:ERROR:gpu_channel.cc(449)] GpuChannel: Failed to create SharedImageStub
erik-kz commented 5 months ago

and what I did is just setting of:

__NV_PRIME_RENDER_OFFLOAD=1
__GLX_VENDOR_LIBRARY_NAME=nvidia

in /etc/environment file

I should point out that these variables aren't really intended to be set globally like that. Doing so will force all applications to use the NVIDIA GPU, negating most of the power-saving benefits of a hybrid graphics configuration. The more typical pattern is to only set them when running graphically demanding applications - games, 3D modelling, and so on. That way the NVIDIA GPU will remain powered off most of the time, reducing energy consumption significantly.

Regarding the thumbnail issue, since you have PRIME render-offload enabled globally, plasmashell will presumably be running on the NVIDIA GPU. The compositor, Kwin, should still be running on the Intel GPU, though. I suspect that whatever mechanism KDE uses to share share window thumbnails between those two components might not work when they are running on different GPUs.

Dvergatal commented 5 months ago

Ahhhha OK I have read this link https://wiki.gentoo.org/wiki/Hybrid_graphics#Choosing_when_to_use_the_Nvidia_dGPU as I'm gentoo user and that is what is written out there...