Android blanks out app AFTER lockscreen unlock - did I miss some redraw event or is that an SDL2 oversight/bug?

My app is lazy redraw (only redraws when something changed) using 3d accelerated SDL_Renderer, which works perfectly even when tabbing out and back. However, when locking the screen and unlocking it again, I can BRIEFLY see the original canvas contents, only to see Android fade them to black a second later. As soon as I touch it to force a redraw it works again.

So despite me not blocking the event loop, either SDL2 or Android appear to expect me to redraw after screen unlock. But how am I supposed to know that lock & unlock even happened? Is there some screen unlock or “please redraw” event that I missed? Or is this an SDL2 api limitation/bug?

On desktop, I never had that happen even when going into suspend & waking up again, so it appears to be some Android-specific problem.

did you try redraw in foreground event?

while (SDL_PollEvent(&event) != 0)
{
	switch (event.type)
	{
	case SDL_APP_WILLENTERBACKGROUND:
		//inactive
		break;
	case SDL_APP_WILLENTERFOREGROUND:
		//active
		break;
     }
}
1 Like