question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unavoidable PySDL2 crash on app resume

See original GitHub issue

I 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:

  1. 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.

  2. 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.

  3. 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:closed
  • Created 5 years ago
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Aug 24, 2018

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 separately

1reaction
ghostcommented, Aug 12, 2018

kivy doesn’t seem to use SDL_CreateRenderer or SDL_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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a known issue with Python's Threading and waiting a ...
1). A module I use to use 'global keybinds'. Called 'system_hotkey'. I noticed that the app will have a much higher crash chance...
Read more >
Resume transfer after reboot or app crash with S3 - Forum
Theres no way to resume same big upload of file after reboot or app crash. Like CuteFTP would be nice for S3 or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found