Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroying SDL_Renderer in app background event with the intention to restore it in foreground event leads to crash #1424

Closed
ghost opened this issue Oct 21, 2018 · 13 comments

Comments

@ghost
Copy link

ghost commented Oct 21, 2018

Versions

  • Python: Python 3.6.6
  • OS: built on ubuntu 18 lts, happens on android 7 in multiple variants
  • Kivy: not used
  • Cython: happens without Cython as well

Description

What happens:

Destroying SDL_Renderer in app background event with the intention to restore it in foreground event leads to crash. I tested this on multiple devices, so this is most certainly not a GPU driver bug, but something in either p4a's wrapper or SDL2's SDLActivity that is broken.

The crash happens when you go back into the app inside the wrapper with access to address 0x8 before the app resume event / custom app code happens, so right before control is returned to my own app code.

There is a small chance of the crash not happening, and if it doesn't, everything will work fine from then on in any followup background & resume events. So it seems to be some sort of race condition.

Why would anyone want this to work:

The reason to do this in the first place is to avoid buggy GPU drivers that don't keep the 3d context around, so accessing the SDL_Renderer after background & restore would lead to a crash - hence, the dumping and recreation to avoid that. However, with p4a this doesn't work right now due to this crash.

Why aren't all apps affected by this:

I'm pretty certain kivy is unaffected because it neither uses SDL_Renderer, nor seems to destroy & recreate the context in such a way.

buildozer.spec

not used, but my requirements are not including kivy, just plain SDL2

Logs

09-04 21:29:45.965  1821  4747 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=<removed>/org.kivy.android.PythonActivity (has extras)} from uid 10030 on display 0
09-04 21:29:46.058 23581 23581 V PythonActivity: My oncreate running
09-04 21:29:46.058 23581 23581 V PythonActivity: About to do super onCreate
09-04 21:29:46.058 23581 23581 V SDL     : Device: serranoltexx
09-04 21:29:46.059 23581 23581 V SDL     : Model: GT-I9195
09-04 21:29:46.059 23581 23581 V SDL     : onCreate():org.kivy.android.PythonActivity@44d09ff
09-04 21:29:46.059 23581 23581 V PythonActivity: Did super onCreate
09-04 21:29:46.059 23581 23581 V SDL     : getting identifier
09-04 21:29:46.059 23581 23581 V SDL     : kind is drawable and name presplash
09-04 21:29:46.059 23581 23581 V SDL     : result is 2130837506
09-04 21:29:46.079 23581 23581 V SDL     : asked to get string presplash_color
09-04 21:29:46.079 23581 23581 V SDL     : getting identifier
09-04 21:29:46.079 23581 23581 V SDL     : kind is string and name presplash_color
09-04 21:29:46.079 23581 23581 V SDL     : result is 2130968577
09-04 21:29:46.099 23581 23581 V PythonActivity: onResume()
09-04 21:29:46.100 23581 23581 V SDL     : onResume()
09-04 21:29:46.146 23581 23598 I OpenGLRenderer: Initialized EGL, version 1.4
09-04 21:29:46.146 23581 23598 D OpenGLRenderer: Swap behavior 1
09-04 21:29:46.152  1821  1857 D Sensors : LightSensor readEvents x = 15.000000, raw = 15
09-04 21:29:46.165 23581 23581 V SDL     : onWindowFocusChanged(): true
09-04 21:29:46.172 23581 24009 V PythonActivity: Ready to unpack
09-04 21:29:46.217 23581 24009 V PythonActivity: UNPACKING!!! private app
09-04 21:29:46.217 23581 24009 V SDL     : asked to get string private_version
09-04 21:29:46.217 23581 24009 V SDL     : getting identifier
09-04 21:29:46.251 23581 24009 V SDL     : kind is string and name private_version
09-04 21:29:46.284  1821  1842 I ActivityManager: Displayed <removed>/org.kivy.android.PythonActivity: +255ms (total +19s423ms)
09-04 21:29:46.298 23581 24009 V SDL     : result is 2130968578
09-04 21:29:46.299 23581 24009 V PythonActivity: Data version is 1536088926.6077693
09-04 21:29:46.347 23581 23581 V pythonutil: Checking pattern libcrystax\.so against libSDL2_mixer.so
09-04 21:29:46.347 23581 23581 V pythonutil: Checking pattern libcrystax\.so against libSDL2_ttf.so
09-04 21:29:46.347 23581 23581 V pythonutil: Checking pattern libcrystax\.so against libmain.so
09-04 21:29:46.347 23581 23581 V pythonutil: Checking pattern libcrystax\.so against libSDL2.so
09-04 21:29:46.347 23581 23581 V pythonutil: Checking pattern libcrystax\.so against libcrystax.so
09-04 21:29:46.348 23581 23581 V pythonutil: Pattern libcrystax\.so matched file libcrystax.so
09-04 21:29:46.348 23581 23581 V pythonutil: Checking pattern libcrystax\.so against libSDL2_image.so
09-04 21:29:46.348 23581 23581 V pythonutil: Checking pattern libcrystax\.so against libpython3.5m.so
09-04 21:29:46.348 23581 23581 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_mixer.so
09-04 21:29:46.348 23581 23581 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_ttf.so
09-04 21:29:46.348 23581 23581 V pythonutil: Checking pattern libsqlite3\.so against libmain.so
09-04 21:29:46.348 23581 23581 V pythonutil: Checking pattern libsqlite3\.so against libSDL2.so
09-04 21:29:46.349 23581 23581 V pythonutil: Checking pattern libsqlite3\.so against libcrystax.so
09-04 21:29:46.349 23581 23581 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_image.so
09-04 21:29:46.349 23581 23581 V pythonutil: Checking pattern libsqlite3\.so against libpython3.5m.so
09-04 21:29:46.349 23581 23581 V pythonutil: Checking pattern libssl.*\.so against libSDL2_mixer.so
09-04 21:29:46.349 23581 23581 V pythonutil: Checking pattern libssl.*\.so against libSDL2_ttf.so
09-04 21:29:46.349 23581 23581 V pythonutil: Checking pattern libssl.*\.so against libmain.so
09-04 21:29:46.350 23581 23581 V pythonutil: Checking pattern libssl.*\.so against libSDL2.so
09-04 21:29:46.350 23581 23581 V pythonutil: Checking pattern libssl.*\.so against libcrystax.so
09-04 21:29:46.350 23581 23581 V pythonutil: Checking pattern libssl.*\.so against libSDL2_image.so
09-04 21:29:46.350 23581 23581 V pythonutil: Checking pattern libssl.*\.so against libpython3.5m.so
09-04 21:29:46.350 23581 23581 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_mixer.so
09-04 21:29:46.350 23581 23581 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_ttf.so
09-04 21:29:46.351 23581 23581 V pythonutil: Checking pattern libcrypto.*\.so against libmain.so
09-04 21:29:46.351 23581 23581 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2.so
09-04 21:29:46.353 23581 23581 V pythonutil: Checking pattern libcrypto.*\.so against libcrystax.so
09-04 21:29:46.353 23581 23581 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_image.so
09-04 21:29:46.353 23581 23581 V pythonutil: Checking pattern libcrypto.*\.so against libpython3.5m.so
09-04 21:29:46.353 23581 23581 V pythonutil: Loading library: crystax
09-04 21:29:46.354 23581 23581 V pythonutil: Loading library: SDL2
09-04 21:29:46.354 23581 23581 V pythonutil: Loading library: SDL2_image
09-04 21:29:46.354 23581 23581 V pythonutil: Loading library: SDL2_mixer
09-04 21:29:46.355 23581 23581 V pythonutil: Loading library: SDL2_ttf
09-04 21:29:46.355 23581 23581 V pythonutil: Loading library: python2.7
09-04 21:29:46.357 23581 23581 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/base.apk"],nativeLibraryDirectories=[/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/lib/arm, /system/fake-libs, /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libpython2.7.so"
09-04 21:29:46.357 23581 23581 V pythonutil: Loading library: python3.5m
09-04 21:29:46.357 23581 23581 V pythonutil: Loading library: main
09-04 21:29:46.358 23581 23581 V pythonutil: Failed to load _io.so or unicodedata.so...but that's okay.
09-04 21:29:46.359 23581 23581 V pythonutil: Unsatisfied linker when loading ctypes
09-04 21:29:46.359 23581 23581 V pythonutil: Loaded everything!
09-04 21:29:46.365 23581 23581 V PythonActivity: Setting env vars for start.c and Python to use
09-04 21:29:46.365 23581 23581 V PythonActivity: Access to our meta-data...
09-04 21:29:46.368 23581 23581 I PythonActivity: Surface will NOT be transparent
09-04 21:29:46.442 23581 23581 V SDL     : surfaceCreated()
09-04 21:29:46.442 23581 23581 V SDL     : surfaceChanged()
09-04 21:29:46.442 23581 23581 V SDL     : pixel format RGB_565
09-04 21:29:46.443 23581 23581 V SDL     : Window size:540x924
09-04 21:29:46.447  1821  2416 D Sensors : setDelay: acc_delay=20000000, mag_delay=200000000
09-04 21:29:46.447  1821  2416 D Sensors : setDelay: handle=0, delay=20000000
09-04 21:29:46.449 23581 24019 I SDL     : SDL_Android_Init()
09-04 21:29:46.449 23581 24019 I SDL     : SDL_Android_Init() finished!
09-04 21:29:46.449 23581 24019 I python  : Initialize Python for Android
09-04 21:29:46.449 23581 24019 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
09-04 21:29:46.449 23581 24019 I python  : /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/<removed>/files/app
09-04 21:29:46.449 23581 24019 I python  : Preparing to initialize python
09-04 21:29:46.450 23581 24019 I python  : crystax_python exists
09-04 21:29:46.450 23581 24019 I python  : calculated paths to be...
09-04 21:29:46.450 23581 24019 I python  : /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/<removed>/files/app/crystax_python/stdlib.zip:/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/<removed>/files/app/crystax_python/modules
09-04 21:29:46.450 23581 24019 I python  : set wchar paths...
09-04 21:29:46.450 23581 24019 I python  : Initialized python
09-04 21:29:46.450 23581 24019 I python  : AND: Init threads
--------- beginning of crash
09-04 21:29:46.454 23581 24019 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x8 in tid 24019 (SDLThread)
09-04 21:29:46.457   176   176 W         : debuggerd: handling request: pid=23581 uid=10183 gid=10183 tid=24019
09-04 21:29:46.479 24021 24021 W debuggerd: type=1400 audit(0.0:28): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.479 24021 24021 W debuggerd: type=1400 audit(0.0:29): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.479 24021 24021 W debuggerd: type=1400 audit(0.0:30): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.479 24021 24021 W debuggerd: type=1400 audit(0.0:31): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.479 24021 24021 W debuggerd: type=1400 audit(0.0:32): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.479 24021 24021 W debuggerd: type=1400 audit(0.0:33): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.489 24021 24021 W debuggerd: type=1400 audit(0.0:34): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.489 24021 24021 W debuggerd: type=1400 audit(0.0:35): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.489 24021 24021 W debuggerd: type=1400 audit(0.0:36): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.489 24021 24021 W debuggerd: type=1400 audit(0.0:37): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.489 24021 24021 W debuggerd: type=1400 audit(0.0:38): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.519 24021 24021 W debuggerd: type=1400 audit(0.0:39): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.529 24021 24021 W debuggerd: type=1400 audit(0.0:40): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.699 24021 24021 W debuggerd: type=1400 audit(0.0:41): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.705 24021 24021 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-04 21:29:46.706 24021 24021 F DEBUG   : LineageOS Version: '14.1-20180624-NIGHTLY-serranoltexx'
09-04 21:29:46.706 24021 24021 F DEBUG   : Build fingerprint: 'samsung/serranoltexx/serranolte:4.4.2/KOT49H/I9195XXUCNE6:user/release-keys'
09-04 21:29:46.706 24021 24021 F DEBUG   : Revision: '0'
09-04 21:29:46.706 24021 24021 F DEBUG   : ABI: 'arm'
09-04 21:29:46.707 24021 24021 F DEBUG   : pid: 23581, tid: 24019, name: SDLThread  >>> <removed> <<<
09-04 21:29:46.707 24021 24021 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
09-04 21:29:46.707 24021 24021 F DEBUG   :     r0 9ab5cb60  r1 00000008  r2 8b7debb5  r3 00000000
09-04 21:29:46.707 24021 24021 F DEBUG   :     r4 aa01b4a6  r5 9ab5cb60  r6 b45d5008  r7 9c8ebe0c
09-04 21:29:46.707 24021 24021 F DEBUG   :     r8 9c8ebf0c  r9 9b2e5f00  sl 00000000  fp 9c8ec080
09-04 21:29:46.707 24021 24021 F DEBUG   :     ip 9d052bdc  sp 9c8ebdc0  lr 9ce810d5  pc 9ce80b7e  cpsr 600e0030
09-04 21:29:46.709 24021 24021 W debuggerd: type=1400 audit(0.0:42): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.719 24021 24021 W debuggerd: type=1400 audit(0.0:43): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:46.722 24021 24021 F DEBUG   : 
09-04 21:29:46.722 24021 24021 F DEBUG   : backtrace:
09-04 21:29:46.722 24021 24021 F DEBUG   :     #00 pc 0004cb7e  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/lib/arm/libpython3.5m.so
09-04 21:29:46.722 24021 24021 F DEBUG   :     #01 pc 0004d0d1  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/lib/arm/libpython3.5m.so
09-04 21:29:46.722 24021 24021 F DEBUG   :     #02 pc 0004d3cb  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/lib/arm/libpython3.5m.so
09-04 21:29:46.722 24021 24021 F DEBUG   :     #03 pc 00060b27  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/lib/arm/libpython3.5m.so
09-04 21:29:46.722 24021 24021 F DEBUG   :     #04 pc 00001045  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/lib/arm/libmain.so
09-04 21:29:46.722 24021 24021 F DEBUG   :     #05 pc 00000dfd  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/lib/arm/libmain.so
09-04 21:29:46.722 24021 24021 F DEBUG   :     #06 pc 00000a41  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/<removed>/oat/arm/base.odex (offset 0x16000)
09-04 21:29:47.153  1821  1857 D Sensors : LightSensor readEvents x = 8.000000, raw = 8
09-04 21:29:47.160  1821  1844 D LuxLevels: bright hysteresis constant= 0.1, threshold=14.036187, lux=12.76017
09-04 21:29:47.160  1821  1844 D LuxLevels: dark hysteresis constant= 0.2, threshold=10.208137, lux=12.76017
09-04 21:29:47.751 24021 24021 W debuggerd: type=1400 audit(0.0:44): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:47.761 24021 24021 W debuggerd: type=1400 audit(0.0:45): avc: denied { search } for name="expand" dev="tmpfs" ino=6594 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
09-04 21:29:48.107   176   176 W         : debuggerd: resuming target 23581
09-04 21:29:48.122  1821  1839 I BootReceiver: Copying /data/tombstones/tombstone_01 to DropBox (SYSTEM_TOMBSTONE)
09-04 21:29:48.153  1821  1857 D Sensors : LightSensor readEvents x = 8.000000, raw = 8
09-04 21:29:48.173  1821  5933 I WindowManager: WIN DEATH: Window{1082b0f u0 <removed>/org.kivy.android.PythonActivity}
09-04 21:29:48.173  1821  5933 W WindowManager: Force-removing child win Window{79ac5a5 u0 SurfaceView - <removed>/org.kivy.android.PythonActivity} from container Window{1082b0f u0 <removed>/org.kivy.android.PythonActivity}
09-04 21:29:48.173  1821  2416 D GraphicsStats: Buffer count: 11
09-04 21:29:48.185  1821 24026 W ActivityManager:   Force finishing activity <removed>/org.kivy.android.PythonActivity
09-04 21:29:48.195  1821  1856 D Sensors : setDelay: acc_delay=66667000, mag_delay=200000000
09-04 21:29:48.195  1821  1875 W InputDispatcher: channel '7581a2f <removed>/org.kivy.android.PythonActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
09-04 21:29:48.195  1821  1856 D Sensors : setDelay: handle=0, delay=66667000
09-04 21:29:48.195  1821  1875 E InputDispatcher: channel '7581a2f <removed>/org.kivy.android.PythonActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
09-04 21:29:48.198  1457  1457 I Zygote  : Process 23581 exited due to signal (11)
09-04 21:29:48.205  1821  4747 W WindowManager: Failed looking up window
09-04 21:29:48.205  1821  4747 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@a33179c does not exist
09-04 21:29:48.205  1821  4747 W WindowManager: 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9469)
09-04 21:29:48.205  1821  4747 W WindowManager: 	at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9460)
09-04 21:29:48.205  1821  4747 W WindowManager: 	at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1807)
09-04 21:29:48.205  1821  4747 W WindowManager: 	at android.os.BinderProxy.sendDeathNotice(Binder.java:688)
09-04 21:29:48.205  1821  4747 I WindowManager: WIN DEATH: null
09-04 21:29:48.205  1821  5122 I WindowManager: WIN DEATH: Window{74a8be u0 SurfaceView - <removed>/org.kivy.android.PythonActivity}
09-04 21:29:48.209  1821  5066 I WindowManager: WIN DEATH: Window{7581a2f u0 <removed>/org.kivy.android.PythonActivity}
09-04 21:29:48.209  1821  5066 W InputDispatcher: Attempted to unregister already unregistered input channel '7581a2f <removed>/org.kivy.android.PythonActivity (server)'
09-04 21:29:48.238  1821 24026 W ActivityManager: Exception thrown during pause
09-04 21:29:48.238  1821 24026 W ActivityManager: android.os.DeadObjectException
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at android.os.BinderProxy.transactNative(Native Method)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at android.os.BinderProxy.transact(Binder.java:615)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at android.app.ApplicationThreadProxy.schedulePauseActivity(ApplicationThreadNative.java:785)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1148)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3585)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3421)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:1860)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.handleAppCrashLocked(AppErrors.java:625)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.makeAppCrashingLocked(AppErrors.java:483)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.crashApplicationInner(AppErrors.java:358)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.crashApplication(AppErrors.java:309)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:13694)
09-04 21:29:48.238  1821 24026 W ActivityManager: 	at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
09-04 21:29:48.243  1821 24026 I ActivityManager: Restarting because process died: ActivityRecord{2049812 u0 <removed>/org.kivy.android.PythonActivity t3528}
09-04 21:29:48.247  1821 24026 W ActivityManager: Exception when starting activity <removed>/org.kivy.android.PythonActivity
09-04 21:29:48.247  1821 24026 W ActivityManager: android.os.DeadObjectException
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at android.os.BinderProxy.transactNative(Native Method)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at android.os.BinderProxy.transact(Binder.java:615)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at android.app.ApplicationThreadProxy.scheduleLaunchActivity(ApplicationThreadNative.java:884)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStackSupervisor.realStartActivityLocked(ActivityStackSupervisor.java:1314)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStackSupervisor.startSpecificActivityLocked(ActivityStackSupervisor.java:1413)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.resumeTopActivityInnerLocked(ActivityStack.java:2573)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.resumeTopActivityUncheckedLocked(ActivityStack.java:2137)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStackSupervisor.resumeFocusedStackTopActivityLocked(ActivityStackSupervisor.java:1838)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStackSupervisor.resumeFocusedStackTopActivityLocked(ActivityStackSupervisor.java:1828)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.startPausingLocked(ActivityStack.java:1203)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.finishActivityLocked(ActivityStack.java:3585)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStack.finishTopRunningActivityLocked(ActivityStack.java:3421)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked(ActivityStackSupervisor.java:1860)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.handleAppCrashLocked(AppErrors.java:625)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.makeAppCrashingLocked(AppErrors.java:483)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.crashApplicationInner(AppErrors.java:358)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.AppErrors.crashApplication(AppErrors.java:309)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.ActivityManagerService.handleApplicationCrashInner(ActivityManagerService.java:13694)
09-04 21:29:48.247  1821 24026 W ActivityManager: 	at com.android.server.am.NativeCrashListener$NativeCrashReporter.run(NativeCrashListener.java:86)
09-04 21:29:48.247  1821 24026 D ActivityManager: cleanUpApplicationRecord -- 23581
09-04 21:29:48.260  1821 24026 I ActivityManager: Start proc 24029:<removed>/u0a183 for activity <removed>/org.kivy.android.PythonActivity
09-04 21:29:48.260  1821  4748 W ActivityManager: Spurious death for ProcessRecord{1ed61d2 24029:<removed>/u0a183}, curProc for 23581: null

@ghost ghost self-assigned this Jan 30, 2019
@inclement
Copy link
Member

Did you ever work this out? Is it a p4a or sdl2 issue? Did SDL 2.0.9 maybe affect it?

@ghost
Copy link
Author

ghost commented Jan 31, 2019

@inclement yes the crash is definitely still happening, although not triggered only by renderer change (that just seems to make it more likely). I was simply busy with other things, but before I release my app I'll have to debug this and find out. It's some race condition with leaving & coming back

I suspect it's a bug in either SDLActivity.java, PythonActivity.java or SDL2 native code. Can't say more without debugging it deeper

@brvier
Copy link
Contributor

brvier commented Mar 6, 2019

Did you use a background service ? For me, It s look like it try to resume the service

@ghost
Copy link
Author

ghost commented Mar 6, 2019

@brvier nope, none of that at all, just a boring "regular" app. (I haven't even checked out how to do a service yet)

However it occurred to me that in recent time I have become one of the active python-for-android contributors best suited to debug this. (since I poked around so much in SDL2 for the recent big upgrade) So I'll bite, I just haven't gotten around to it yet. No need to invest time unless you're curious or you want to solve this crash faster for yourself 👍

@brvier
Copy link
Contributor

brvier commented Mar 8, 2019

No need to invest time unless you're curious or you want to solve this crash faster for yourself

Both in fact :)

@brvier
Copy link
Contributor

brvier commented Mar 21, 2019

03-21 11:31:54.910 10034 10034 V SDL : CONTROLLER nativeSetupJNI()
03-21 11:31:54.918 10034 10034 V SDL : onResume()
03-21 11:31:54.929 10034 10034 V SDL : surfaceCreated()
03-21 11:31:54.929 10034 10034 V SDL : surfaceChanged()
03-21 11:31:54.929 10034 10034 V SDL : pixel format RGB_565
03-21 11:31:54.929 10034 10034 V SDL : Window size: 1080x1848
03-21 11:31:54.929 10034 10034 V SDL : Device size: 1080x1920
03-21 11:31:54.934 10034 10034 V SDL : nativeResume()
03-21 11:31:54.934 10034 10160 V SDL : Running main function SDL_main from library /data/app/xxxxx/lib/arm/libmain.so
03-21 11:31:54.934 10034 10160 V SDL : nativeRunMain()
03-21 11:31:54.936 10034 10160 F libc : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 10160 (SDLThread)

Could this be related https://bugzilla.libsdl.org/show_bug.cgi?id=4142

@ghost
Copy link
Author

ghost commented Mar 21, 2019

Not sure, now that I'm looking at the backtrace again, it actually looks like it's crashing inside python and not in libSDL2. (which I would expect if this was a synchronization issue in some internal SDL2 data structure) I think the only way to find out what is really happening is to check in gdb

@brvier
Copy link
Contributor

brvier commented Mar 28, 2019

#if PY_MAJOR_VERSION < 3
  initandroidembed();
#endif

Crash occur in initandroidembed of start.c for me ...
https://github.com/kivy/python-for-android/blob/1db60cf3d76fa4451cbce22921b3310cb9983494/pythonforandroid/bootstraps/common/build/jni/application/src/start.c

@ghost
Copy link
Author

ghost commented Apr 5, 2019

I'm just thinking, if you see this right at the app start you should probably file a separate ticket. The crash here was purely when returning to the app when it was in background in between, so if that is not what you're getting it's probably something different

Also I just noticed I could no longer reproduce it since I revamped some of my SDL_Renderer code to never touch things while in background & after bumping the SDL2 version to fix something unrelated: #1779

So it appears whatever I saw was either my own fault, or an SDL2 bug. Are you still seeing crashes, and when exactly are they occurring for you? (app launch, or later?)

@brvier
Copy link
Contributor

brvier commented Apr 5, 2019

Yes indeed, i was making more test, but this is not related.

The crash i got is in fact two disctinct bugs :

  • In Service, foreground service should not be killed when front task is killed.
  • In SDLActivity if a thread never ends in apps, it ll never clean up everything on onDestroy

@ghost
Copy link
Author

ghost commented Apr 5, 2019

Oops, the web form ate half my comment, here it is again:

Okay, could you possibly create tickets for these then? Because I think what I saw is gone, so it's probably the most reasonable approach if I close this ticket now

In SDLActivity if a thread never ends in apps, it ll never clean up everything on onDestroy

For what it's worth, that sounds like it is probably not easily avoidable / might be an inherent NDK issue. So I wonder if that's not a bug but just something the app needs to avoid doing...? But maybe the others got some input on that (for what it's worth, python has these daemon threads that get auto-terminated when the main thread exits. maybe using something like that would help?) Or does that also happen if the other threads exit with a small delay? That would indeed be quite a problem

@brvier
Copy link
Contributor

brvier commented Apr 5, 2019

Okay, could you possibly create tickets for these then? Because I think what I saw is gone, so it's probably the most reasonable approach if I close this ticket now

Indeed you can close, other ticket are already created.

#1783 #1784
#1785 #1786
#1787 #1787

@ghost
Copy link
Author

ghost commented Apr 5, 2019

Ok, thanks for the feedback! I'll close this ticket then

@ghost ghost closed this as completed Apr 5, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants