Bug 394445

Summary: Taskbar doesn't repaint when running SDL application
Product: [Plasma] plasmashell Reporter: Paul <bugskde>
Component: Task Manager and Icons-Only Task Manager widgetsAssignee: Eike Hein <hein>
Status: RESOLVED DUPLICATE    
Severity: normal CC: cfeck, plasma-bugs
Priority: NOR    
Version: 5.8.6   
Target Milestone: 1.0   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Paul 2018-05-19 13:30:07 UTC
Below a minimal SDL application that creates a window and quits when the user closes a window.
(no painting takes place, so the contents of the window look a bit weird)
When running the application, the taskbar panel stops being repainted. On my computer the taskbar consist of the application launcher, desktop switcher, task manager, system tray icons, clock and panel edit button. They all keep looking the same. But clicking on the taskbar still works (the right action is executed, still no repaint though) and hovering still shows popups. When quitting the application, everything is back to normal.
When restarting the application, everything goes back to the way it looked when I started the application for the first time.

test.cpp:

#include <SDL2/SDL.h>

int main ()
{
	// Initialize
	SDL_Init(SDL_INIT_VIDEO);
	SDL_Window *window = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 800, 600, SDL_WINDOW_SHOWN);

	// Loop
	SDL_Event e;
	while (SDL_WaitEvent(&e)) {
		if (e.type == SDL_QUIT) return 0;
	}
	return 1;
}

Compile with: gcc -lSDL2 -o test test.cpp

I'm only using updated software from the Debian Stable repository. The SDL version is 2.0.5.
If this may be a bug in SDL instead or an error on my part, let me know.
Comment 1 Paul 2018-05-19 13:41:10 UTC
As a bad workaround I now use SDL_WINDOW_SHOWN | SDL_WINDOW_UTILITY | SDL_WINDOW_ALWAYS_ON_TOP instead of SDL_WINDOW_SHOWN. The SDL_WINDOW_UTILITY prevents the window to be added to the taskbar, so the problem does not occur. But then I have to add SDL_WINDOW_ALWAYS_ON_TOP because otherwise it is difficult to get the window back once an other window is in front of it.
Comment 2 Christoph Feck 2018-05-19 13:45:12 UTC
Are you using NVIDIA OpenGL drivers?

SDL stops compositing (you can avoid it with a window flag), so this is likely bug 353983.
Comment 3 Christoph Feck 2018-05-19 13:54:47 UTC
https://hg.libsdl.org/SDL/rev/dfde5d3f9781
Comment 4 Paul 2018-05-19 14:22:00 UTC
Yes, I'm using NVIDIA OpenGL drivers and this indeed seems to be bug 353983. 

$ glxinfo | grep OpenGL
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 550 Ti/PCIe/SSE2
OpenGL core profile version string: 4.5.0 NVIDIA 375.82
OpenGL core profile shading language version string: 4.50 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.5.0 NVIDIA 375.82
OpenGL shading language version string: 4.50 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 375.82
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:

For others reading this: The quick fix is to open "Compositor" via the application launcher and uncheck "Allow applications to block compositing". This can reduce performance. It's also possible to not allow block compositing for specific windows.
Comment 5 Christoph Feck 2018-05-19 14:53:47 UTC
Or, for SDL2 games, run the game in Konsole with

SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR=0 gamename

*** This bug has been marked as a duplicate of bug 353983 ***
Comment 6 Paul 2018-05-19 16:44:35 UTC
The "SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR=0 gamename" doesn't work at my system for the test app I provided.