kivy / python-for-android

Turn your Python application into an Android APK
https://python-for-android.readthedocs.io
MIT License
8.28k stars 1.84k forks source link

Unavoidable PySDL2 crash on app resume #1323

Closed ghost closed 6 years ago

ghost commented 6 years ago

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.

ghost commented 6 years ago

I made a minimal reproduction case.

  1. Write this into your main.py file:
    
    #!/usr/bin/env python3

def apply_hack(): import ctypes.util orig_func = ctypes.util.find_library def android_find_library_hack(*args): import os name = args[0]

    # Truncate ending for easier comparison:
    if name.find(".so.") >= 0:
        name = name.partition(".so.")[0]
    if name.endswith(".so"):
        name = name[:-len(".so")]
    if not name.endswith("."):
        name += "."

    # Helper function to check lib name:
    def check_name(lib_name, search_name):
        if filename.endswith('.so') and (
                filename.startswith("lib" + search_name) or
                filename.startswith(search_name)):
            return True
        if search_name.endswith("-2.0."):  # PySDL2 hack
            search_name = search_name[:-len("-2.0.")] + "."
            return check_name(lib_name, search_name)
        return False

    # Check the user app lib dir and system dir:
    app_root = os.path.normpath(os.path.abspath(os.path.join(
        os.path.dirname(__file__), '..', '..', 'lib')))
    sys_dir = "/system/lib"
    for lib_search in [app_root, sys_dir]:
        if not os.path.exists(lib_search):
            continue
        for filename in os.listdir(lib_search):
            if check_name(filename, name):
                return os.path.join(lib_search, filename)
    return orig_func(*args)
import ctypes.util
ctypes.util.find_library = android_find_library_hack

apply_hack()

import ctypes import sdl2 as sdl import sys import time import traceback

window = None renderer = None

def test_app(): global window, renderer print("Creating window (app launch)...") sdl.SDL_Init(sdl.SDL_INIT_EVERYTHING) window = sdl.SDL_CreateWindow( "This is a test.".encode("utf-8", "replace"), sdl.SDL_WINDOWPOS_CENTERED, sdl.SDL_WINDOWPOS_CENTERED, 640, 480, sdl.SDL_WINDOW_SHOWN | sdl.SDL_WINDOW_RESIZABLE) renderer = sdl.SDL_CreateRenderer(window, -1, 0)

# Main event loop:
while True:
    time.sleep(0.01)

    # Fetch events:
    events = []
    while True:
        ev = sdl.SDL_Event()
        result = sdl.SDL_PollEvent(ctypes.byref(ev))
        if result == 1:
            events.append(ev)
            continue
        break
    for event in events:
        handle_event(event)

def handle_event(event): global window, renderer

if event.type == sdl.SDL_QUIT or \
        event.type == sdl.SDL_APP_TERMINATING:
    print("Terminating (app termination event).")
    if renderer != None:
        sdl.SDL_DestroyRenderer(renderer)
        renderer = None
    if window != None:
        sdl.SDL_DestroyWindow(window)
        window = None
    sys.exit(0)
elif event.type == sdl.SDL_WINDOWEVENT:
    if event.window.event == \
            sdl.SDL_WINDOWEVENT_CLOSE:
        # Throw away renderer:
        if renderer != None:
            sdl.SDL_DestroyRenderer(renderer)
            renderer = None
            print("Renderer destroyed (window closed).")
        # Close window:
        if window != None:
            sdl.SDL_DestroyWindow(window)
            window = None
            print("Window destroyed (window closed).")
            # Terminate if not on android:
            if sdl.SDL_GetPlatform().decode("utf-8").\
                    lower() != "android":
                print("Terminating app since on desktop OS, " +
                    "and last window was closed.")
                sys.exit(0)
    if (event.window.event ==
            sdl.SDL_WINDOWEVENT_RESTORED or
            event.window.event ==
            sdl.SDL_WINDOWEVENT_EXPOSED or
            event.window.event ==
            sdl.SDL_WINDOWEVENT_MAXIMIZED):
        # Re-create renderer if necessary:
        if renderer == None:
            print("Renderer re-created (got window focus).")
            renderer = sdl.SDL_CreateRenderer(window, -1, 0)
elif (event.type == sdl.SDL_APP_DIDENTERBACKGROUND):
    print("Entered background.")
    # Wipe renderer:
    if renderer != None:
        sdl.SDL_DestroyRenderer(renderer)
        renderer = None
        print("Renderer destroyed (entered background).")
elif (event.type == sdl.SDL_APP_WILLENTERFOREGROUND):
    print("Entering foreground.")
    # Re-create window if necessary:
    if window == None:
        window = sdl.SDL_CreateWindow(
            "This is a test.".encode("utf-8", "replace"),
            sdl.SDL_WINDOWPOS_CENTERED, sdl.SDL_WINDOWPOS_CENTERED,
            640, 480, sdl.SDL_WINDOW_SHOWN |
            sdl.SDL_WINDOW_RESIZABLE)
        if renderer != None:
            sdl.SDL_DestroyRenderer(renderer)
            renderer = None
            print("Renderer destroyed (new window).")
    # Re-create renderer if necessary:
    if renderer == None:
        renderer = sdl.SDL_CreateRenderer(window, -1, 0)
        print("Renderer re-created (entering foreground).")

test_app()


2. Compile with `p4a apk --debug --private /path/to/folder/with/main.py/in/it/ --orientation user --window --package=org.example.myapp --name "My application" --version 0.1 --bootstrap=sdl2 --requirements=python3crystax,sdl2,pysdl2,pyjnius --arch=armeabi-v7a`  (or equivalent command line)

3. Install the `.apk` on your phone
4. Open app, wait a bit to make sure extraction is complete (check `extracting` messages in logcat) - the loading screen won't ever go away because the app never redraws or does anything useful
5. Press home button to leave app
6. Return to app -> instant crash

This app works perfectly fine on the desktop, and I don't see why it shouldn't on Android - so I suggest with the reproduction case as a starting point, it would be worth investigating why `python-for-android` crashes with this.
inclement commented 6 years ago

I'm not that familiar with SDL2's event loop expectations, but this seems fairly likely to be more of an SDL2 issue than a p4a one - most of p4a's code builds on the Android project provided by SDL2.

I guess things I would look into might include:

Also, do you have the logcat logs from the crash? There's probably something in there about it.

ghost commented 6 years ago

I bugged the minimal reproduction case and managed to fix it now (the code above is now edited accordingly), and here is the logcat from that:

08-11 18:31:22.597 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_ebs_test.py
08-11 18:31:22.598 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_draw_test.py
08-11 18:31:22.599 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdlimage_test.py
08-11 18:31:22.600 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_image_test.py
08-11 18:31:22.601 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/version_test.py
08-11 18:31:22.602 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdlttf_test.py
08-11 18:31:22.603 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_gui_test.py
08-11 18:31:22.604 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/audio_test.py
08-11 18:31:22.605 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_sprite_test.py
08-11 18:31:22.607 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_events_test.py
08-11 18:31:22.608 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/cpuinfo_test.py
08-11 18:31:22.609 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/keyboard_test.py
08-11 18:31:22.611 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/log_test.py
08-11 18:31:22.612 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/surface_test.py
08-11 18:31:22.614 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/clipboard_test.py
08-11 18:31:22.615 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_font_test.py
08-11 18:31:22.616 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/filesystem_test.py
08-11 18:31:22.617 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/render_test.py
08-11 18:31:22.619 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdlmixer_test.py
08-11 18:31:22.620 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/rect_test.py
08-11 18:31:22.621 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/__init__.py
08-11 18:31:22.622 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_color_test.py
08-11 18:31:22.624 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/syswm_test.py
08-11 18:31:22.624 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/platform_test.py
08-11 18:31:22.625 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/mouse_test.py
08-11 18:31:22.626 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/events_test.py
08-11 18:31:22.628 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdlgfx_test.py
08-11 18:31:22.629 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_test.py
08-11 18:31:22.630 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/endian_test.py
08-11 18:31:22.631 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/rwops_test.py
08-11 18:31:22.632 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/joystick_test.py
08-11 18:31:22.633 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_pixelaccess_test.py
08-11 18:31:22.634 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_resources_test.py
08-11 18:31:22.635 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/shape_test.py
08-11 18:31:22.636 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_array_test.py
08-11 18:31:22.637 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_algorithms_test.py
08-11 18:31:22.639 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/sdl2ext_particles_test.py
08-11 18:31:22.640 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/util/
08-11 18:31:22.666 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/util/support.py
08-11 18:31:22.667 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/util/testrunner.py
08-11 18:31:22.668 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/util/testutils.py
08-11 18:31:22.669 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/util/runtests.py
08-11 18:31:22.698 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/util/__init__.py
08-11 18:31:22.699 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/
08-11 18:31:22.717 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.pnm
08-11 18:31:22.721 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.ppm
08-11 18:31:22.725 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.jpg
08-11 18:31:22.728 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.xpm
08-11 18:31:22.732 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/rwopstest.txt
08-11 18:31:22.734 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.bmp
08-11 18:31:22.736 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.webp
08-11 18:31:22.739 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.pcx
08-11 18:31:22.741 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.pgm
08-11 18:31:22.743 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.xcf
08-11 18:31:22.745 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.ico
08-11 18:31:22.747 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.tif
08-11 18:31:22.749 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.pbm
08-11 18:31:22.750 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.cur
08-11 18:31:22.752 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/resources.tar.gz
08-11 18:31:22.753 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/font.bmp
08-11 18:31:22.762 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/resources.zip
08-11 18:31:22.763 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.gif
08-11 18:31:22.767 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/tuffy.ttf
08-11 18:31:22.796 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/tuffy.copy.ttf
08-11 18:31:22.821 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.png
08-11 18:31:22.822 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.tga
08-11 18:31:22.823 13277 13294 V python  : extracting crystax_python/site-packages/sdl2/test/resources/surfacetest.lbm
08-11 18:31:22.824 13277 13294 V python  : extracting crystax_python/site-packages/pyjnius-1.1.2.dev0.egg-info/
08-11 18:31:22.831 13277 13294 V python  : extracting crystax_python/site-packages/pyjnius-1.1.2.dev0.egg-info/requires.txt
08-11 18:31:22.832 13277 13294 V python  : extracting crystax_python/site-packages/pyjnius-1.1.2.dev0.egg-info/PKG-INFO
08-11 18:31:22.835 13277 13294 V python  : extracting crystax_python/site-packages/pyjnius-1.1.2.dev0.egg-info/top_level.txt
08-11 18:31:22.836 13277 13294 V python  : extracting crystax_python/site-packages/pyjnius-1.1.2.dev0.egg-info/dependency_links.txt
08-11 18:31:22.839 13277 13294 V python  : extracting crystax_python/site-packages/pyjnius-1.1.2.dev0.egg-info/SOURCES.txt
08-11 18:31:22.843 13277 13294 V python  : extracting crystax_python/modules/
08-11 18:31:22.845 13277 13294 V python  : extracting crystax_python/modules/_multiprocessing.so
08-11 18:31:22.864 13277 13294 V python  : extracting crystax_python/modules/_sqlite3.so
08-11 18:31:23.112 13277 13294 V python  : extracting crystax_python/modules/pyexpat.so
08-11 18:31:23.160 13277 13294 V python  : extracting crystax_python/modules/unicodedata.so
08-11 18:31:23.278 13277 13294 V python  : extracting crystax_python/modules/_socket.so
08-11 18:31:23.299 13277 13294 V python  : extracting crystax_python/modules/_ctypes.so
08-11 18:31:23.340 13277 13294 V python  : extracting crystax_python/modules/select.so
08-11 18:31:23.488  2070  2106 D Sensors : LightSensor readEvents x = 4.000000, raw = 4
08-11 18:31:23.664 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2_mixer.so
08-11 18:31:23.664 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2_ttf.so
08-11 18:31:23.664 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libmain.so
08-11 18:31:23.664 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2.so
08-11 18:31:23.664 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libcrystax.so
08-11 18:31:23.665 13277 13277 V pythonutil: Pattern libcrystax\.so matched file libcrystax.so
08-11 18:31:23.665 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2_image.so
08-11 18:31:23.665 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libpython3.5m.so
08-11 18:31:23.666 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_mixer.so
08-11 18:31:23.666 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_ttf.so
08-11 18:31:23.666 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libmain.so
08-11 18:31:23.666 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2.so
08-11 18:31:23.666 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libcrystax.so
08-11 18:31:23.666 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_image.so
08-11 18:31:23.667 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libpython3.5m.so
08-11 18:31:23.667 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2_mixer.so
08-11 18:31:23.668 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2_ttf.so
08-11 18:31:23.668 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libmain.so
08-11 18:31:23.668 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2.so
08-11 18:31:23.668 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libcrystax.so
08-11 18:31:23.668 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2_image.so
08-11 18:31:23.668 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libpython3.5m.so
08-11 18:31:23.669 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_mixer.so
08-11 18:31:23.669 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_ttf.so
08-11 18:31:23.669 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libmain.so
08-11 18:31:23.669 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2.so
08-11 18:31:23.670 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libcrystax.so
08-11 18:31:23.670 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_image.so
08-11 18:31:23.670 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libpython3.5m.so
08-11 18:31:23.673 13277 13277 V pythonutil: Loading library: crystax
08-11 18:31:23.696 13277 13277 V pythonutil: Loading library: SDL2
08-11 18:31:23.853 13277 13277 V pythonutil: Loading library: SDL2_image
08-11 18:31:23.860 13277 13277 V pythonutil: Loading library: SDL2_mixer
08-11 18:31:23.866 13277 13277 V pythonutil: Loading library: SDL2_ttf
08-11 18:31:23.871 13277 13277 V pythonutil: Loading library: python2.7
08-11 18:31:23.917 13277 13277 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/base.apk"],nativeLibraryDirectories=[/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm, /system/fake-libs, /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libpython2.7.so"
08-11 18:31:23.917 13277 13277 V pythonutil: Loading library: python3.5m
08-11 18:31:23.923 13277 13277 V pythonutil: Loading library: main
08-11 18:31:23.927 13277 13277 V pythonutil: Failed to load _io.so or unicodedata.so...but that's okay.
08-11 18:31:23.927 13277 13277 V pythonutil: Unsatisfied linker when loading ctypes
08-11 18:31:23.927 13277 13277 V pythonutil: Loaded everything!
08-11 18:31:24.167 13277 13277 V PythonActivity: Setting env vars for start.c and Python to use
08-11 18:31:24.167 13277 13277 V PythonActivity: Access to our meta-data...
08-11 18:31:24.200 13277 13277 I PythonActivity: Surface will NOT be transparent
08-11 18:31:24.225 13277 13277 V SDL     : surfaceCreated()
08-11 18:31:24.225 13277 13277 V SDL     : surfaceChanged()
08-11 18:31:24.225 13277 13277 V SDL     : pixel format RGB_565
08-11 18:31:24.226 13277 13277 V SDL     : Window size:540x924
08-11 18:31:24.260  2070  2888 D Sensors : setDelay: acc_delay=20000000, mag_delay=200000000
08-11 18:31:24.260  2070  2888 D Sensors : setDelay: handle=0, delay=20000000
08-11 18:31:24.269 13277 13305 I SDL     : SDL_Android_Init()
08-11 18:31:24.269 13277 13305 I SDL     : SDL_Android_Init() finished!
08-11 18:31:24.269 13277 13305 I python  : Initialize Python for Android
08-11 18:31:24.269 13277 13305 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
08-11 18:31:24.270 13277 13305 I python  : /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app
08-11 18:31:24.270 13277 13305 I python  : Preparing to initialize python
08-11 18:31:24.270 13277 13305 I python  : crystax_python exists
08-11 18:31:24.270 13277 13305 I python  : calculated paths to be...
08-11 18:31:24.270 13277 13305 I python  : /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/crystax_python/stdlib.zip:/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/crystax_python/modules
08-11 18:31:24.270 13277 13305 I python  : set wchar paths...
08-11 18:31:24.489  2070  2106 D Sensors : LightSensor readEvents x = 5.000000, raw = 5
08-11 18:31:24.889 13277 13305 I python  : Initialized python
08-11 18:31:24.889 13277 13305 I python  : AND: Init threads
08-11 18:31:24.890 13277 13305 I python  : testing python print redirection
08-11 18:31:24.894 13277 13305 I python  : Android path ['.', '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/crystax_python/stdlib.zip', '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/crystax_python/modules', '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/crystax_python/site-packages']
08-11 18:31:24.895 13277 13305 I python  : os.environ is environ({'DOWNLOAD_CACHE': '/cache', 'PATH': '/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin', 'PYTHONHOME': '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app', 'ANDROID_ASSETS': '/system/app', 'BOOTCLASSPATH': '/system/framework/core-oj.jar:/system/framework/core-libart.jar:/system/framework/conscrypt.jar:/system/framework/okhttp.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/apache-xml.jar:/system/framework/org.apache.http.legacy.boot.jar:/system/framework/telephony-ext.jar', 'ANDROID_STORAGE': '/storage', 'TERMINFO': '/system/etc/terminfo', 'PYTHON_NAME': 'python', 'LD_PRELOAD': 'libsigchain.so', 'SYSTEMSERVERCLASSPATH': '/system/framework/org.cyanogenmod.platform.jar:/system/framework/org.cyanogenmod.hardware.jar:/system/framework/services.jar:/system/framework/ethernet-service.jar:/system/framework/wifi-service.jar', 'ANDROID_SOCKET_zygote': '9', 'ANDROID_ROOT': '/system', 'EXTERNAL_STORAGE': '/sdcard', 'ANDROID_DATA': '/data', 'ANDROID_CACHE': '/cache', 'ANDROID_ENTRYPOINT': 'main.pyo', 'ANDROID_UNPACK': '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app', 'PYTHONOPTIMIZE': '2', 'PYTHONPATH': '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app:/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/lib', 'ANDROID_BOOTLOGO': '1', 'ANDROID_ARGUMENT': '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app', 'ANDROID_PRIVATE': '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files', 'ASEC_MOUNTPOINT': '/mnt/asec', 'LD_SHIM_LIBS': '/system/lib/libril.so|libshim_ril.so:/system/bin/mm-qcamera-daemon|libshim_camera.so', 'ANDROID_APP_PATH': '/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app'})
08-11 18:31:24.895 13277 13305 I python  : Android kivy bootstrap done. __name__ is __main__
08-11 18:31:24.896 13277 13305 I python  : AND: Ran string
08-11 18:31:24.896 13277 13305 I python  : Run user program, change dir and execute entrypoint
08-11 18:31:24.896 13277 13305 I python  : main.py
08-11 18:31:25.489  2070  2106 D Sensors : LightSensor readEvents x = 5.000000, raw = 5
08-11 18:31:26.489  2070  2106 D Sensors : LightSensor readEvents x = 5.000000, raw = 5
08-11 18:31:26.490  2070  2093 D LuxLevels: bright hysteresis constant= 0.1, threshold=5.119377, lux=4.6539793
08-11 18:31:26.490  2070  2093 D LuxLevels: dark hysteresis constant= 0.2, threshold=3.7231834, lux=4.6539793
08-11 18:31:26.754 13277 13305 I python  : CHECK NAME ('libSDL2_mixer.so', 'SDL2.')
08-11 18:31:26.755 13277 13305 I python  : CHECK NAME ('libSDL2_ttf.so', 'SDL2.')
08-11 18:31:26.755 13277 13305 I python  : CHECK NAME ('libmain.so', 'SDL2.')
08-11 18:31:26.755 13277 13305 I python  : CHECK NAME ('libSDL2.so', 'SDL2.')
08-11 18:31:26.755 13277 13305 I python  : CHECK NAME ('libSDL2_mixer.so', 'SDL2-2.0.')
08-11 18:31:26.756 13277 13305 I python  : CHECK NAME ('libSDL2_mixer.so', 'SDL2.')
08-11 18:31:26.756 13277 13305 I python  : CHECK NAME ('libSDL2_ttf.so', 'SDL2-2.0.')
08-11 18:31:26.756 13277 13305 I python  : CHECK NAME ('libSDL2_ttf.so', 'SDL2.')
08-11 18:31:26.756 13277 13305 I python  : CHECK NAME ('libmain.so', 'SDL2-2.0.')
08-11 18:31:26.756 13277 13305 I python  : CHECK NAME ('libmain.so', 'SDL2.')
08-11 18:31:26.756 13277 13305 I python  : CHECK NAME ('libSDL2.so', 'SDL2-2.0.')
08-11 18:31:26.756 13277 13305 I python  : CHECK NAME ('libSDL2.so', 'SDL2.')
08-11 18:31:27.219 13277 13305 I python  : Creating window (app launch)...
08-11 18:31:27.489  2070  2106 D Sensors : LightSensor readEvents x = 5.000000, raw = 5
08-11 18:31:28.000  1705  1745 I ThermalDaemon: Sensor 'tsens_tz_sensor0' - alarm cleared 1 at 47.0 degC
08-11 18:31:28.489  2070  2106 D Sensors : LightSensor readEvents x = 5.000000, raw = 5
08-11 18:31:29.489  2070  2106 D Sensors : LightSensor readEvents x = 5.000000, raw = 5
08-11 18:31:30.489  2070  2106 D Sensors : LightSensor readEvents x = 4.000000, raw = 4
08-11 18:31:31.489  2070  2106 D Sensors : LightSensor readEvents x = 4.000000, raw = 4
08-11 18:31:32.489  2070  2106 D Sensors : LightSensor readEvents x = 10.000000, raw = 10
08-11 18:31:33.493  2070  2106 D Sensors : LightSensor readEvents x = 1.000000, raw = 1
08-11 18:31:34.442  2070  2128 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10200000 cmp=com.cyanogenmod.trebuchet/com.android.launcher3.Launcher (has extras)} from uid 1000 on display 0
08-11 18:31:34.453 13277 13277 V PythonActivity: onPause()
08-11 18:31:34.453 13277 13277 V SDL     : onPause()
08-11 18:31:34.454 13277 13277 V SDL     : nativePause()
08-11 18:31:34.454 13277 13277 E libEGL  : call to OpenGL ES API with no current context (logged once per thread)
08-11 18:31:34.455  2070  8708 D Sensors : setDelay: acc_delay=66667000, mag_delay=200000000
08-11 18:31:34.455  2070  8708 D Sensors : setDelay: handle=0, delay=66667000
08-11 18:31:34.462 13277 13305 I python  : Entered background.
08-11 18:31:34.469 13277 13305 I python  : Renderer destroyed (entered background).
08-11 18:31:34.476 13277 13277 V SDL     : onWindowFocusChanged(): false
08-11 18:31:34.489  2070  2106 D Sensors : LightSensor readEvents x = 1.000000, raw = 1
08-11 18:31:34.648 13277 13277 V SDL     : surfaceDestroyed()
08-11 18:31:34.869  2070  2080 I art     : Background partial concurrent mark sweep GC freed 76537(3MB) AllocSpace objects, 8(160KB) LOS objects, 33% free, 15MB/22MB, paused 2.350ms total 392.369ms
08-11 18:31:35.405  2922  3001 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
08-11 18:31:35.405  2922  3001 W OpenGLRenderer: Incorrectly called buildLayer on View: ShortcutAndWidgetContainer, destroying layer...
08-11 18:31:35.490  2070  2106 D Sensors : LightSensor readEvents x = 1.000000, raw = 1
08-11 18:31:36.489  2070  2106 D Sensors : LightSensor readEvents x = 1.000000, raw = 1
08-11 18:31:36.799 30233 30244 I art     : Background sticky concurrent mark sweep GC freed 71853(3MB) AllocSpace objects, 0(0B) LOS objects, 43% free, 4MB/8MB, paused 5.035ms total 44.925ms
08-11 18:31:37.489  2070  2106 D Sensors : LightSensor readEvents x = 1.000000, raw = 1
08-11 18:31:37.496  2070  2093 D LuxLevels: bright hysteresis constant= 0.1, threshold=1.4798616, lux=1.3453287
08-11 18:31:37.496  2070  2093 D LuxLevels: dark hysteresis constant= 0.2, threshold=1.076263, lux=1.3453287
08-11 18:31:38.488  2070  2106 D Sensors : LightSensor readEvents x = 1.000000, raw = 1
08-11 18:31:38.489  2070  2093 D LuxLevels: bright hysteresis constant= 0.1, threshold=1.1000136, lux=1.0000124
08-11 18:31:38.489  2070  2093 D LuxLevels: dark hysteresis constant= 0.2, threshold=0.8000099, lux=1.0000124
08-11 18:31:39.489  2070  2106 D Sensors : LightSensor readEvents x = 2.000000, raw = 2
08-11 18:31:39.772  2070  2888 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=org.example.myapp/org.kivy.android.PythonActivity (has extras)} from uid 10030 on display 0
08-11 18:31:39.840 13277 13277 V PythonActivity: My oncreate running
08-11 18:31:39.840 13277 13277 V PythonActivity: About to do super onCreate
08-11 18:31:39.840 13277 13277 V SDL     : Device: serranoltexx
08-11 18:31:39.840 13277 13277 V SDL     : Model: GT-I9195
08-11 18:31:39.841 13277 13277 V SDL     : onCreate():org.kivy.android.PythonActivity@c8626c7
08-11 18:31:39.841 13277 13277 V PythonActivity: Did super onCreate
08-11 18:31:39.841 13277 13277 V SDL     : getting identifier
08-11 18:31:39.841 13277 13277 V SDL     : kind is drawable and name presplash
08-11 18:31:39.841 13277 13277 V SDL     : result is 2130837506
08-11 18:31:39.868 13277 13277 V SDL     : asked to get string presplash_color
08-11 18:31:39.868 13277 13277 V SDL     : getting identifier
08-11 18:31:39.868 13277 13277 V SDL     : kind is string and name presplash_color
08-11 18:31:39.869 13277 13277 V SDL     : result is 2130968577
08-11 18:31:39.879 13277 13277 V PythonActivity: onResume()
08-11 18:31:39.879 13277 13277 V SDL     : onResume()
08-11 18:31:39.949 13277 13375 V PythonActivity: Ready to unpack
08-11 18:31:39.949 13277 13375 V PythonActivity: UNPACKING!!! private app
08-11 18:31:39.950 13277 13375 V SDL     : asked to get string private_version
08-11 18:31:39.950 13277 13375 V SDL     : getting identifier
08-11 18:31:39.950 13277 13375 V SDL     : kind is string and name private_version
08-11 18:31:39.970 13277 13277 V SDL     : onWindowFocusChanged(): true
08-11 18:31:40.019 13277 13375 V SDL     : result is 2130968578
08-11 18:31:40.019 13277 13375 V PythonActivity: Data version is 1534004771.2852473
08-11 18:31:40.021 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2_mixer.so
08-11 18:31:40.021 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2_ttf.so
08-11 18:31:40.021 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libmain.so
08-11 18:31:40.021 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2.so
08-11 18:31:40.021 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libcrystax.so
08-11 18:31:40.021 13277 13277 V pythonutil: Pattern libcrystax\.so matched file libcrystax.so
08-11 18:31:40.021 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libSDL2_image.so
08-11 18:31:40.022 13277 13277 V pythonutil: Checking pattern libcrystax\.so against libpython3.5m.so
08-11 18:31:40.022 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_mixer.so
08-11 18:31:40.022 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_ttf.so
08-11 18:31:40.022 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libmain.so
08-11 18:31:40.023 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2.so
08-11 18:31:40.023 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libcrystax.so
08-11 18:31:40.023 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libSDL2_image.so
08-11 18:31:40.023 13277 13277 V pythonutil: Checking pattern libsqlite3\.so against libpython3.5m.so
08-11 18:31:40.024 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2_mixer.so
08-11 18:31:40.024 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2_ttf.so
08-11 18:31:40.024 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libmain.so
08-11 18:31:40.024 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2.so
08-11 18:31:40.024 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libcrystax.so
08-11 18:31:40.025 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libSDL2_image.so
08-11 18:31:40.025 13277 13277 V pythonutil: Checking pattern libssl.*\.so against libpython3.5m.so
08-11 18:31:40.025 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_mixer.so
08-11 18:31:40.026 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_ttf.so
08-11 18:31:40.027 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libmain.so
08-11 18:31:40.027 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2.so
08-11 18:31:40.027 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libcrystax.so
08-11 18:31:40.027 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libSDL2_image.so
08-11 18:31:40.027 13277 13277 V pythonutil: Checking pattern libcrypto.*\.so against libpython3.5m.so
08-11 18:31:40.028 13277 13277 V pythonutil: Loading library: crystax
08-11 18:31:40.028 13277 13277 V pythonutil: Loading library: SDL2
08-11 18:31:40.028 13277 13277 V pythonutil: Loading library: SDL2_image
08-11 18:31:40.029 13277 13277 V pythonutil: Loading library: SDL2_mixer
08-11 18:31:40.029 13277 13277 V pythonutil: Loading library: SDL2_ttf
08-11 18:31:40.029 13277 13277 V pythonutil: Loading library: python2.7
08-11 18:31:40.031 13277 13277 V pythonutil: Library loading error: dalvik.system.PathClassLoader[DexPathList[[zip file "/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/base.apk"],nativeLibraryDirectories=[/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm, /system/fake-libs, /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]] couldn't find "libpython2.7.so"
08-11 18:31:40.031 13277 13277 V pythonutil: Loading library: python3.5m
08-11 18:31:40.031 13277 13277 V pythonutil: Loading library: main
08-11 18:31:40.032 13277 13277 V pythonutil: Failed to load _io.so or unicodedata.so...but that's okay.
08-11 18:31:40.033 13277 13277 V pythonutil: Unsatisfied linker when loading ctypes
08-11 18:31:40.033 13277 13277 V pythonutil: Loaded everything!
08-11 18:31:40.041 13277 13277 V PythonActivity: Setting env vars for start.c and Python to use
08-11 18:31:40.042 13277 13277 V PythonActivity: Access to our meta-data...
08-11 18:31:40.048 13277 13277 I PythonActivity: Surface will NOT be transparent
08-11 18:31:40.163 13386 13386 W debuggerd: type=1400 audit(0.0:257): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.163 13386 13386 W debuggerd: type=1400 audit(0.0:258): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.049  2070  2091 I ActivityManager: Displayed org.example.myapp/org.kivy.android.PythonActivity: +233ms
08-11 18:31:40.073 13277 13277 V SDL     : surfaceCreated()
08-11 18:31:40.074 13277 13277 V SDL     : surfaceChanged()
08-11 18:31:40.074 13277 13277 V SDL     : pixel format RGB_565
08-11 18:31:40.074 13277 13277 V SDL     : Window size:540x924
08-11 18:31:40.089  2070  2467 D Sensors : setDelay: acc_delay=20000000, mag_delay=200000000
08-11 18:31:40.089  2070  2467 D Sensors : setDelay: handle=0, delay=20000000
08-11 18:31:40.103 13277 13384 I SDL     : SDL_Android_Init()
08-11 18:31:40.103 13277 13384 I SDL     : SDL_Android_Init() finished!
08-11 18:31:40.103 13277 13384 I python  : Initialize Python for Android
08-11 18:31:40.103 13277 13384 I python  : Changing directory to the one provided by ANDROID_ARGUMENT
08-11 18:31:40.103 13277 13384 I python  : /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app
08-11 18:31:40.103 13277 13384 I python  : Preparing to initialize python
08-11 18:31:40.103 13277 13384 I python  : crystax_python exists
08-11 18:31:40.103 13277 13384 I python  : calculated paths to be...
08-11 18:31:40.103 13277 13384 I python  : /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/crystax_python/stdlib.zip:/mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/user/0/org.example.myapp/files/app/crystax_python/modules
08-11 18:31:40.103 13277 13384 I python  : set wchar paths...
08-11 18:31:40.103 13277 13384 I python  : Initialized python
08-11 18:31:40.103 13277 13384 I python  : AND: Init threads
08-11 18:31:40.113 13277 13384 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x8 in tid 13384 (SDLThread)
08-11 18:31:40.115   177   177 W         : debuggerd: handling request: pid=13277 uid=10134 gid=10134 tid=13384
08-11 18:31:40.163 13386 13386 W debuggerd: type=1400 audit(0.0:259): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.163 13386 13386 W debuggerd: type=1400 audit(0.0:260): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.173 13386 13386 W debuggerd: type=1400 audit(0.0:261): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.173 13386 13386 W debuggerd: type=1400 audit(0.0:262): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.183 13386 13386 W debuggerd: type=1400 audit(0.0:263): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.193 13386 13386 W debuggerd: type=1400 audit(0.0:264): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.203 13386 13386 W debuggerd: type=1400 audit(0.0:265): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.233 13386 13386 W debuggerd: type=1400 audit(0.0:266): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.256 30233 30244 I art     : Background sticky concurrent mark sweep GC freed 69624(3MB) AllocSpace objects, 0(0B) LOS objects, 42% free, 4MB/8MB, paused 10.956ms total 87.105ms
08-11 18:31:40.318 13386 13386 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
08-11 18:31:40.318 13386 13386 F DEBUG   : LineageOS Version: '14.1-20180624-NIGHTLY-serranoltexx'
08-11 18:31:40.318 13386 13386 F DEBUG   : Build fingerprint: 'samsung/serranoltexx/serranolte:4.4.2/KOT49H/I9195XXUCNE6:user/release-keys'
08-11 18:31:40.318 13386 13386 F DEBUG   : Revision: '0'
08-11 18:31:40.318 13386 13386 F DEBUG   : ABI: 'arm'
08-11 18:31:40.318 13386 13386 F DEBUG   : pid: 13277, tid: 13384, name: SDLThread  >>> org.example.myapp <<<
08-11 18:31:40.318 13386 13386 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
08-11 18:31:40.319 13386 13386 F DEBUG   :     r0 9c3dcd18  r1 00000008  r2 a2f49124  r3 00000000
08-11 18:31:40.319 13386 13386 F DEBUG   :     r4 aa04f4a6  r5 9c3dcd18  r6 b5cf5008  r7 9beafe0c
08-11 18:31:40.319 13386 13386 F DEBUG   :     r8 9beaff0c  r9 90e9db00  sl 00000000  fp 9beb0080
08-11 18:31:40.319 13386 13386 F DEBUG   :     ip 9d066bdc  sp 9beafdc0  lr 9ce950d5  pc 9ce94b7e  cpsr 600b0030
08-11 18:31:40.313 13386 13386 W debuggerd: type=1400 audit(0.0:267): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.313 13386 13386 W debuggerd: type=1400 audit(0.0:268): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.323 13386 13386 W debuggerd: type=1400 audit(0.0:269): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:40.333 13386 13386 F DEBUG   : 
08-11 18:31:40.333 13386 13386 F DEBUG   : backtrace:
08-11 18:31:40.333 13386 13386 F DEBUG   :     #00 pc 0004cb7e  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm/libpython3.5m.so
08-11 18:31:40.334 13386 13386 F DEBUG   :     #01 pc 0004d0d1  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm/libpython3.5m.so
08-11 18:31:40.335 13386 13386 F DEBUG   :     #02 pc 0004d3cb  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm/libpython3.5m.so
08-11 18:31:40.335 13386 13386 F DEBUG   :     #03 pc 00060b27  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm/libpython3.5m.so
08-11 18:31:40.335 13386 13386 F DEBUG   :     #04 pc 00001045  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm/libmain.so
08-11 18:31:40.335 13386 13386 F DEBUG   :     #05 pc 00000dfd  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/lib/arm/libmain.so
08-11 18:31:40.335 13386 13386 F DEBUG   :     #06 pc 00000aa1  /mnt/expand/ccbe4e94-5878-4053-8382-d825486cc844/app/org.example.myapp-1/oat/arm/base.odex (offset 0x16000)
08-11 18:31:40.489  2070  2106 D Sensors : LightSensor readEvents x = 2.000000, raw = 2
08-11 18:31:41.474 13386 13386 W debuggerd: type=1400 audit(0.0:270): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:41.474 13386 13386 W debuggerd: type=1400 audit(0.0:271): avc: denied { search } for name="expand" dev="tmpfs" ino=3826 scontext=u:r:debuggerd:s0 tcontext=u:object_r:mnt_expand_file:s0 tclass=dir permissive=0
08-11 18:31:41.488  2070  2106 D Sensors : LightSensor readEvents x = 2.000000, raw = 2
08-11 18:31:41.491  2070  2093 D LuxLevels: bright hysteresis constant= 0.1, threshold=1.819631, lux=1.65421
08-11 18:31:41.491  2070  2093 D LuxLevels: dark hysteresis constant= 0.2, threshold=1.323368, lux=1.65421
08-11 18:31:41.757   177   177 W         : debuggerd: resuming target 13277
08-11 18:31:41.773  2070 13392 W ActivityManager:   Force finishing activity org.example.myapp/org.kivy.android.PythonActivity
08-11 18:31:41.795  2070  8708 I WindowManager: WIN DEATH: Window{dd51e11 u0 org.example.myapp/org.kivy.android.PythonActivity}
08-11 18:31:41.795  2070  8708 W WindowManager: Force-removing child win Window{f13e5e4 u0 SurfaceView - org.example.myapp/org.kivy.android.PythonActivity} from container Window{dd51e11 u0 org.example.myapp/org.kivy.android.PythonActivity}
08-11 18:31:41.797  2070  2921 D GraphicsStats: Buffer count: 14
08-11 18:31:41.799  2070  2128 W InputDispatcher: channel '9d5d16d org.example.myapp/org.kivy.android.PythonActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
08-11 18:31:41.799  2070  2128 E InputDispatcher: channel '9d5d16d org.example.myapp/org.kivy.android.PythonActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
08-11 18:31:41.803  2070  2467 I ActivityManager: Process org.example.myapp (pid 13277) has died
08-11 18:31:41.803  2070  2467 D ActivityManager: cleanUpApplicationRecord -- 13277
08-11 18:31:41.820  2070  2088 I BootReceiver: Copying /data/tombstones/tombstone_00 to DropBox (SYSTEM_TOMBSTONE)
08-11 18:31:41.829  2070 21516 I WindowManager: WIN DEATH: Window{9d5d16d u0 org.example.myapp/org.kivy.android.PythonActivity}
08-11 18:31:41.829  2070 21516 W InputDispatcher: Attempted to unregister already unregistered input channel '9d5d16d org.example.myapp/org.kivy.android.PythonActivity (server)'
08-11 18:31:41.829  2070 21516 W WindowManager: Force-removing child win Window{defda8f u0 SurfaceView - org.example.myapp/org.kivy.android.PythonActivity} from container Window{9d5d16d u0 org.example.myapp/org.kivy.android.PythonActivity}
08-11 18:31:41.852  2070  2105 D Sensors : setDelay: acc_delay=66667000, mag_delay=200000000
08-11 18:31:41.852  2070  2105 D Sensors : setDelay: handle=0, delay=66667000
08-11 18:31:41.866  1707  1707 I Zygote  : Process 13277 exited due to signal (11)
08-11 18:31:41.871  2070 31112 W WindowManager: Failed looking up window
08-11 18:31:41.871  2070 31112 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@d1125ee does not exist
08-11 18:31:41.871  2070 31112 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9469)
08-11 18:31:41.871  2070 31112 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9460)
08-11 18:31:41.871  2070 31112 W WindowManager:     at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1807)
08-11 18:31:41.871  2070 31112 W WindowManager:     at android.os.BinderProxy.sendDeathNotice(Binder.java:688)
08-11 18:31:41.872  2070 31112 I WindowManager: WIN DEATH: null
08-11 18:31:41.872  2070  2913 W WindowManager: Failed looking up window
08-11 18:31:41.872  2070  2913 W WindowManager: java.lang.IllegalArgumentException: Requested window android.os.BinderProxy@d1da577 does not exist
08-11 18:31:41.872  2070  2913 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9469)
08-11 18:31:41.872  2070  2913 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9460)
08-11 18:31:41.872  2070  2913 W WindowManager:     at com.android.server.wm.WindowState$DeathRecipient.binderDied(WindowState.java:1807)
08-11 18:31:41.872  2070  2913 W WindowManager:     at android.os.BinderProxy.sendDeathNotice(Binder.java:688)
08-11 18:31:41.872  2070  2913 I WindowManager: WIN DEATH: null
08-11 18:31:41.892 13394 13394 I art     : Late-enabling -Xcheck:jni
08-11 18:31:41.927  2070  2467 I ActivityManager: Start proc 13394:org.example.myapp/u0a134 for activity org.example.myapp/org.kivy.android.PythonActivity
08-11 18:31:41.997 13394 13394 V PythonActivity: My oncreate running
08-11 18:31:41.997 13394 13394 V PythonActivity: About to do super onCreate
08-11 18:31:41.997 13394 13394 V SDL     : Device: serranoltexx
08-11 18:31:41.997 13394 13394 V SDL     : Model: GT-I9195
08-11 18:31:41.998 13394 13394 V SDL     : onCreate():null
08-11 18:31:41.998 13394 13394 V PythonActivity: Did super onCreate
08-11 18:31:41.998 13394 13394 V SDL     : getting identifier
08-11 18:31:41.998 13394 13394 V SDL     : kind is drawable and name presplash
08-11 18:31:41.999 13394 13394 V SDL     : result is 2130837506
08-11 18:31:42.001  2070 20115 I OpenGLRenderer: Initialized EGL, version 1.4
08-11 18:31:42.001  2070 20115 D OpenGLRenderer: Swap behavior 1
08-11 18:31:42.022 13394 13394 V SDL     : asked to get string presplash_color
08-11 18:31:42.022 13394 13394 V SDL     : getting identifier
08-11 18:31:42.022 13394 13394 V SDL     : kind is string and name presplash_color
08-11 18:31:42.023 13394 13394 V SDL     : result is 2130968577
08-11 18:31:42.046 13394 13394 V PythonActivity: onResume()
08-11 18:31:42.046 13394 13394 V SDL     : onResume()
08-11 18:31:42.055 13394 13411 V PythonActivity: Ready to unpack
08-11 18:31:42.055 13394 13411 V PythonActivity: UNPACKING!!! private app
08-11 18:31:42.055 13394 13411 V SDL     : asked to get string private_version
08-11 18:31:42.075 13394 13411 V SDL     : getting identifier
08-11 18:31:42.080 13394 13411 V SDL     : kind is string and name private_version
08-11 18:31:42.082 13394 13411 V SDL     : result is 2130968578
08-11 18:31:42.082 13394 13411 V PythonActivity: Data version is 1534004771.2852473
08-11 18:31:42.123 13394 13394 V pythonutil: Checking pattern libcrystax\.so against libSDL2_mixer.so
08-11 18:31:42.123 13394 13394 V pythonutil: Checking pattern libcrystax\.so against libSDL2_ttf.so
08-11 18:31:42.123 13394 13394 V pythonutil: Checking pattern libcrystax\.so against libmain.so
08-11 18:31:42.123 13394 13394 V pythonutil: Checking pattern libcrystax\.so against libSDL2.so
08-11 18:31:42.123 13394 13394 V pythonutil: Checking pattern libcrystax\.so against libcrystax.so
08-11 18:31:42.124 13394 13394 V pythonutil: Pattern libcrystax\.so matched file libcrystax.so
08-11 18:31:42.124 13394 13394 V pythonutil: Checking pattern libcrysta
ghost commented 6 years ago

(Possibly) important things to observe:

  1. There is no output of Entering foreground. or Renderer re-created (got window focus). This means, there was no attempt of the program to recreate the renderer that was destroyed when leaving the app - and the window is still around.

  2. Unless I am extremely mistaken about my own code flow of the minimal example, I don't do anything else other than attempting to re-create the window (but that one is still around) or the renderer - and read events. Most importantly, I don't access neither the window nor the renderer in any other way, since I'm not actually drawing things.

Therefore, I really don't see why it should crash on resume before I even attempt to do stuff, unless the python-for-android wrapper is doing something before it even gets back into my code that crashes things.

As for kivy, I have no idea since I neither have a test app for that, nor can I even build it. I didn't get around to filing a ticket for that yet due to the many other issues I ran into so far

inclement commented 6 years ago

As for kivy, I have no idea since I neither have a test app for that, nor can I even build it.

I was actually thinking at just looking at the code, at least to start with. Kivy gets the events from SDL2 here and processes them here. From a quick look, it doesn't look like Kivy attempts to destroy or recreate its window when paused, but I could easily have missed something.

ghost commented 6 years ago

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

ghost commented 6 years ago

For what it's worth, I looked more through the kivy code and couldn't see anything that I should be doing. I couldn't even find a GL context recreation or anything, so with re-creating the renderer, the example code I gave above seems even more cautious in comparison (it should in theory work and not crash even if the whole GL context & all textures are disposed of by the system). So I really don't see how this should crash from an SDL2 API perspective. However, the kivy code is quite lengthy so maybe I missed something.

ghost commented 6 years ago

Here is an .apk that contains the crash example from above (for ARMv7a and newer):

(apk removed by @KeyWeeUsr)

KeyWeeUsr commented 6 years ago

@JonasT please do not share binaries or packages such as apk. Instead write the steps to reproduce the packaging if needed, so that everyone can check the source code for that.

ghost commented 6 years ago

@KeyWeeUsr I already shared the exact steps including the source code to produce that specific .apk here: https://github.com/kivy/python-for-android/issues/1323#issuecomment-412280503 I was just providing this to make it even easier for you guys to check out.

ghost commented 6 years ago

Since gdb attaching from termux didn't work out (due to https://github.com/termux/termux-packages/issues/2733 ) and this crash appears to happen before execution returns to my application (in whatever code runs in the python-for-android wrapper on resume), I really don't know how to debug this further to give you any more details. However, if there is anything more I could try to help you figure this out, I'd be happy to try it. As for trying whether a kivy app crashes, I'm not sure which one since I don't have any project around - but if you have a specific one a mind, I can give it a try if you think that would help.

ghost commented 6 years ago

So does this crash for anyone else at all? I don't have any other device to test on. Just package the example here https://github.com/kivy/python-for-android/issues/1323#issuecomment-412280503 or I could also link an armv7 .apk to make it even quicker to test for any of you, but of course that will only help if you actually leave the link to it up. :man_shrugging:

ghost commented 6 years ago

So it appears it crashes because I forgot SDL_init :laughing: 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