We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4110

Summary: [SDL 2.0.8][FULLSCREEN_DESKTOP] SDL_RenderPresent() updates window only when keyboard events are received
Product: SDL Reporter: BWD <boubacar.diene>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72, boubacar.diene
Version: don't know   
Hardware: x86_64   
OS: Linux   
URL: https://github.com/BoubacarDiene/mmstreamer

Description BWD 2018-03-18 02:02:07 UTC
Hi,

My github project (https://github.com/BoubacarDiene/mmstreamer) used SDL 2.0.5 and was working fine except one "annoying" issue : Long press badly handled which has been fixed in SDL 2.0.8.

For now, SDL is used in that project to mainly create UI and display video frames captured from cameras using v4l2.

I recently decided to move to SDL 2.0.8 and SDL_image 2.0.3 to fix "long press issue" mentioned above and take advantages from the new added features. Thanks for this release but 2 very annoying issues appeared :

Issue 1- Refreshing screen in fullscreen (the purpose of this ticket)

Until now, initializing SDL windows, renderers and waiting for keyboard's events were performed in main thread. However, when it came to updating textures and rendering result to screen to make it visible to users, background threads came into play.

My problem is that this now works as expected only when I'm not in fullscreen mode. In fullscreen mode, the application starts with a black screen in video area until I use keyboard. Each time a keyboard event is received, video area is refreshed.

As a consequence, I was forced to wait for events in two different ways :
- SDL_WaitEvent in normal mode with screen updates done in background thread
- SDL_PollEvent in fullscreen mode with screen updates performed in getEvent function (See https://github.com/BoubacarDiene/mmstreamer/blob/master/src/graphics/drawers/Drawer2.c#L1009)

By using "SDL_PollEvent + SDL_RenderPresent in main thread", I noticed an excessive CPU usage which I never had before with "SDL_WaitEvent + SDL_RenderPresent in background thread".

Why is it two different behaviours (fullscreen vs normal mode)?

Issue 2- SDL_RENDERER_SOFTWARE gives the expected result but not SDL_RENDERER_ACCELERATED

It seems that SDL_RENDERER_ACCELERATED does not work well in my application.

This can be easily tested by replacing SDL_RENDERER_SOFTWARE with SDL_RENDERER_ACCELERATED (or nothing) here : https://github.com/BoubacarDiene/mmstreamer/blob/master/src/graphics/drawers/Drawer2.c#L1255


Please, find here (https://github.com/BoubacarDiene/mmstreamer/blob/master/src/graphics/drawers/Drawer2.c) how SDL 2.0.8 is used in my application.

Best Regards,
Boubacar DIENE
Comment 1 Alex Szpakowski 2018-10-13 05:10:05 UTC
SDL_Render isn't supported at all outside of the main thread.
Comment 2 Sam Lantinga 2018-11-02 23:56:45 UTC
Using a renderer on a different thread isn't supported.