GNOME Bugzilla – Bug 792643
Threaded swap wait + nVidia prop driver + CLUTTER_VBLANK=none freezes screen
Last modified: 2018-08-09 10:25:11 UTC
Created attachment 367017 [details] [review] patch to disable threaded swap wait Having - Nvidia proprietary driver installed - nvidia-drm.modeset=1 set - VBLANK_CLUTTER=none set - mutter-3.24.0 up to 3.26.2 tested leads to frozen screen, i.e. no further screen updates occur. No crashes, mutter reacts to ctrl+c, running fine. I suspect the threaded swap wait introduction: https://bugzilla.gnome.org/show_bug.cgi?id=779039 Setting cogl_xlib_renderer_set_threaded_swap_wait_enabled (cogl_renderer, FALSE); in src/backends/x11/meta-renderer-x11.c reverts to normal operation.
Comment on attachment 367017 [details] [review] patch to disable threaded swap wait That API was added specifically for the proprietary Nvidia driver, so if we wanted to disable it, the patch should remove the feature altogether rather than leaving an unused API around. But rather than working around a bug by disabling the fallback implementation, actually fixing the issue would be much better.
*** This bug has been marked as a duplicate of bug 781835 ***
The patch wasn't meant as fix/workaround but to show that there are more problems with the vsync code than the threaded swap wait changes. Simply put,IIRC, CLUTTER_VBLANK=none sets hasTimer to false. The wait changes are only in parts where if hasTimer==true So the threaded swap wait code should never be reached if the code that has previously been there was correct. Yet turning it off has the effect of making it work again instead of doing a threaded wait for Godot. Fixing this is of course preferred but this is seriously getting harder as more code (-paths) getting added.
I would kindly ask to undupe this bug report as I looked into this and found the logic error that leads to this specific issue. The threaded swap wait emulates glx_intel_swap_event on Nvidia hardware using an extra thread (threaded_swap_wait) using glXWaitVideoSync to wait for vsync and then emit a swap_event. Thus the implementation sets COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT to true. While this works when sync to vblank thus framebuffer->config.swap_throttled is true, in the case of CLUTTER_VBLANK=none framebuffer->config.swap_throttled is set to false which disables threaded_swap_wait so no events are ever emitted. Yet, COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT is still set so waits for events that never happen. So the swap_event emulation only works in the sync'd case and while in theory it would be a cleaner approach to extend that to the unsync'd case in practice that would be just a waste of cycles, emitting continuously swap_events (I don't think that's possible anyway btw.). So attaching a patch taking a more rational approach to disable it conditionally in the unsync'd case.
Created attachment 373289 [details] [review] conditionally disable threaded swap wait
Note that the ability to disable sync-to-vblank is being removed (it was mostly a clutter application feature not really relevant to compositors). See https://gitlab.gnome.org/GNOME/mutter/merge_requests/191/ .
Ok, your decision. This finally makes mutter using the proprietary nvidia driver completely unusable. - The threaded swap wait makes gnome-shell use 30% cpu just moving the mouse - sync to vblank makes window movement like moving in honey. Known problems for up to years. Grrrreat experience. Closing this.