Black screen on_resume()

58 views
Skip to first unread message

Lawrence Du

unread,
Mar 21, 2018, 11:10:07 PM3/21/18
to KivEnt
I've been having an issue which I suspect involves android garbage collection.

When I suspend my app while in my main game screen, the screen goes completely black sometimes when I go back to my app on my android Pixel phone. This is more likely to happen the longer I'm browsing other apps, and doesn't happen in menus which only use kivy (no kivent rendering or update systems are activated)

I have two GameScreens - one of which contain the main game, and another which uses kivent for drawing certain things (planets and stars in the background).

I was able to fix this by basically including an on_pause() method in my app that tells these two gamescreens to pause all kivent systems on sleep, and an on_resume() method that unpauses all kivent systems.

Now this fixes the problem in the short run, but I have actually found that both my app and the kivent game Sneakk will go completely black on_resume() if my phone is in sleep mode for a prolonged period of time.

I have found that this doesn't happen in the main kivy menus. I am not sure if this has been observed on other phones. 


Lawrence Du

unread,
Apr 27, 2018, 7:46:55 PM4/27/18
to KivEnt
For future reference, the solution to this problem is to reload all textures to the texture manager when the program resumes. The bug has something to do with sdl2

cleverm...@gmail.com

unread,
May 4, 2018, 2:24:03 AM5/4/18
to KivEnt
I had this issue with my game Quadropoly, which has similar setup (the main board screen uses kivent to move chips, and Menu screen uses pure kivy). Using Sentry to get logs from the crashes, I realised that when user turns the screen off (as opposed to minimising the app) on_pause method did not get triggered at that instance. Instead, when user turns the screen back on, kivent plays catch up by trying to render all the updates which were in between the screen going off and on, and only then on_pause gets triggered. It looks fine when the period of time for the screen being off is less than 2-5 minutes, but it definately crashes if it was longer. To fix that I have added new variable to count kivent updates (i.e. frames), that gets reset to 0 with any user's action. Once it counts above a certain number (equal to 2-3 minutes) it would change the screen to Menu and pause kivent. I know it is a bit of a hack, but I could not figure out why on_pause gets triggered only after kivent frames have caught up with the time.
Hope it will help someone.

Lawrence Du

unread,
May 8, 2018, 4:16:26 PM5/8/18
to KivEnt
Yes thank you so much! I will try this. Longer pauses still seem to cause the screen to black out for a number of seconds

Jacob Kovac

unread,
May 8, 2018, 4:29:13 PM5/8/18
to Lawrence Du, KivEnt
Hey Everyone,

Someone should open an issue on kivy's github about turning the screen off not actually triggering the on_pause, I am pretty certain that it should do so. Maybe mention the android version and the device that this occurs on in case its not common to all devices and versions.

On the KivEnt side we should probably introduce some method that can be called during on_pause that will pause all the running GameSystems, and keep track of which need to be unpaused when we restore.

On Tue, May 8, 2018 at 1:16 PM, Lawrence Du <larr...@gmail.com> wrote:
Yes thank you so much! I will try this. Longer pauses still seem to cause the screen to black out for a number of seconds

--
You received this message because you are subscribed to the Google Groups "KivEnt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivent+unsubscribe@googlegroups.com.
To post to this group, send email to kiv...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivent/3b40f87e-e510-4ba7-9e98-84fde13a9429%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages