Unavoidable PySDL2 crash on app resume
See original GitHub issueI am using python-for-android & PySDL2 (no kivy) and I am running into an unavoidable crash when pressing the home button and leaving the app, and then returning to it.
I tried a couple of strategies:
-
If I destroy the SDL_Window & SDL_Renderer when I get the background event (
SDL_APP_DIDENTERBACKGROUND
), the app crashes right away (SIGSEGV in SDL2) before it’s even fully in the background. -
If I destroy the SDL_Renderer (
SDL_DestroyRenderer
) but keep the window around, as soon as the app gains focus again, it crashes (SIGSEGV IN SDL2) - this is before I get to process any single event in my code after the resumption, so it’s not like I’ve been drawing or accessing anything. It seems to be a problem in the wrapper during the resume process. -
If I keep window & renderer both around, it similarly crashes on resume. (That one isn’t too surprising, since I imagine the renderer probably needs to be re-created - I just tested it for completeness)
So first of all, what am I even supposed to do? And since I’m pretty sure it’s one of those 3 things, it seems the wrapper is simply broken.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (3 by maintainers)
Top GitHub Comments
So it appears it crashes because I forgot
SDL_init
😆 oops! No idea why my main app crashed, maybe the same reason…? Anyway, the minimal example above works now (I edited to fix it) regarding the tab in/out crashes. I’m having orientation issues but I’ll examine those separatelykivy doesn’t seem to use
SDL_CreateRenderer
orSDL_CreateTexture
but a direct OpenGL context - maybe this is the issue? Maybe the integrated accelerated 2D renderer backend of SDL is something python-for-android simply wasn’t really tested with?Anyway, the above test code is a nice test case which I offer under CC0 / public domain / … if you want to add it to some sort of test suite. It crashes very reliably for me, so it should be pretty suitable to figure out what is going on