| Summary: | Android black screen on resume using OpenGL ES 2.0 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Vitaly Novichkov <admin> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | NEW --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | sylvain.becker |
| Version: | 2.0.14 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
|
Description
Vitaly Novichkov
2021-02-02 22:01:29 UTC
Did you make sure not to call any rendering function between the two events SDL_WILL_ENTER_BACKGROUND and SDL_DID_ENTER_FOREGROUND see docs/README-android.md Oh, interesting, how I messed this up? Gonna try this out... Thanks for the notice! btw, does that also counting the rendering into the texture too? Okay, I'll check. Nope, that didn't help completely, even I made the strict avoiding of any render functions being called, I still can get the black screen and the EGL_BAD_ACCESS error after I switched application back that really really is a reason, are you depleting the event loop ? no multi-threading ? really stop using renderer after reading WILL_ENTER_BG, and start again using DID_ENTER_FG. are you using the SDL_Renderer or your own context ? > are you depleting the event loop ? No, I do call the event loop sequentially > no multi-threading ? No, single threading > really stop using renderer after reading WILL_ENTER_BG, and start again using DID_ENTER_FG. Oh, I did a mistake - I used the WILL_ENTER_FG instead of WILL_ENTER_BG event, I should re-try this experiment again. > are you using the SDL_Renderer or your own context ? I use SDL_Renderer Okay, I really made sure no render will be called between those events, I even added asserts to crash if any of the render calls will be executed after `SDL_APP_WILLENTERBACKGROUND` event, and allow them to be called after `SDL_APP_DIDENTERFOREGROUND` event that unlocks the render. The result is the same, on Android 10: - open the game - switch another application (my log will print the fact "SDL_APP_WILLENTERBACKGROUND" was coming, I made sure those messages be printed to see the result) - All big render calls got blocked by a boolean - All small routine render calls got blocked by assert - Switch the game back (my log will print the fact of "SDL_APP_DIDENTERFOREGROUND") - Black screen I also checked the fact of any attempts to call the render calls, just by spamming of the same message into the log, the spamming is off completely when entering background, and getting on back when entered background.
>> are you depleting the event loop ?
> No, I do call the event loop sequentially
before each frame, and also periodically, you must poll all the events.
Just to make sure, all functions using the SDL_renderer includes: RenderCopy, RenderPresent, CreateTexture, UpdateTexture, ..
> before each frame, and also periodically, you must poll all the events. Yes, that what I already do, I poll all events in every loop cycle > Just to make sure, all functions using the SDL_renderer includes: > CreateTexture, UpdateTexture I don't call them during the loop except for the lazy-decompression algorithm that gets executed when calling the big render call, I blocked by the boolean > RenderCopy, RenderPresent Both blocked by the boolean I do set This look strange ... you have recent SDL2 lib + sync'ed java file ? you can add trace here: http://hg.libsdl.org/SDL/file/1cde3dd0f44d/src/video/android/SDL_androidevents.c to backup and restore context maybe log the event: SDL_RENDER_DEVICE_RESET with those print do you have a full adb log to check ? try with a simpler test case ? Closing to the evening (UTC+3) I'll try to compose a simple test program that simulates my and verify the work. Anyway, without of SDL2 patching, I did the tracking of SDL_RENDER_DEVICE_RESET event, and I got next: ``` 02-04 12:50:08.444 2791-2814/ru.wohlsoft.thextech.debug D/TRACKERS: Android: Entering background 02-04 12:50:16.879 2791-2814/ru.wohlsoft.thextech.debug D/TRACKERS: Android: Resumed foreground 02-04 12:50:19.591 2791-2814/ru.wohlsoft.thextech.debug D/TRACKERS: Android: Entering background 02-04 12:50:23.807 2791-2814/ru.wohlsoft.thextech.debug D/TRACKERS: Android: Resumed foreground 02-04 12:50:27.021 2791-2814/ru.wohlsoft.thextech.debug D/TRACKERS: Android: Entering background 02-04 12:50:32.787 2791-2814/ru.wohlsoft.thextech.debug D/TRACKERS: Android: Resumed foreground 02-04 12:50:32.787 2791-2814/ru.wohlsoft.thextech.debug D/TRACKERS: Android: Render Device Reset ``` I had multiple times to go into the background, and then, resume back, but the thing got blacked once SDL_RENDER_DEVICE_RESET was happened at my log So, seems once this event came: --- SDL_RENDER_TARGETS_RESET the render targets have been reset and their contents need to be updated (>= SDL 2.0.2) SDL_RENDER_DEVICE_RESET the device has been reset and all textures need to be recreated (>= SDL 2.0.4) --- I should reload all the textures again, right? I'll try some in the evening after my workday will finish. yep, re-create texture once you get the device reset. (you don't need to recreate the SDL renderer) Updated the android README file because this is a recurrent issue http://hg.libsdl.org/SDL/rev/8609e27b3eed feel free to improve it! |