| Summary: | SDL_GL_CreateContext crashes on android when SDL_GL_MULTISAMPLESAMPLES is used | ||
|---|---|---|---|
| Product: | SDL | Reporter: | someuniquename |
| Component: | *don't know* | Assignee: | Sylvain <sylvain.becker> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | blocker | ||
| Priority: | P2 | CC: | someuniquename |
| Version: | 2.0.10 | Keywords: | target-2.0.10 |
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: | test.c | ||
|
Description
someuniquename
2019-06-21 12:58:21 UTC
Ah, issue with EGL_BAD_SURFACE is more complicated. For more complex app, even without multisampling the chance of successful start is about 30% this is the adb log of when the app crashes: https://gist.github.com/Fak3/429328b50c9eb11b8c896ad73e236a1a Sylvain, can you look at this ASAP for SDL 2.0.10 release? Thanks! Whoops, didn't mean to mark this fixed. I tried those flags, and I could always start my app and/or create a GL context. I tried several times to makes sure about the 30% ratio. This is not clear, if the issue is with the attributes MULTISAMPLE, it should always happen, right? But if the issue is with the MakeCurrent failing, so it shouldn't be related to your attributes, and fail with any context ?! And you should check when current is made. Maybe, you should try with simple C app to reduce the scope of the issue. Maybe Multisample just makes the bug to appear a bit more reliably, but it is not crucial for the app to crash. Is there any tutorial of how to build an app for android? I bisected and tested my app against repo history. The last known changeset that works fine is this: Android: make sure surfaceChanged try to enter into 'resumed' state. Wed, 02 Jan 2019 17:41:33 +0100 (5 months ago) changeset 12492 fe136f38ab71 Then changesets 12493-12511 crash app because of a different issue, related to concurrency (i think), and throw segfaults. And then the first changeset that fixes concurrency but experince this topic issue with EGL_BAD_SURFACE is this: Android: concurrency issue for Android_SetWindowFullscreen() Wed, 09 Jan 2019 15:18:41 +0100 (5 months ago) changeset 12512 afc8e5d1d992 So the bug was introduced between 02 Jan and 09 Jan, somewhere in changesets 12493-12512 So this commit introduce the issue ? https://hg.libsdl.org/SDL/rev/afc8e5d1d992 It only adds some synchronization to make the function call be atomic. So this is strange :/ Can you try to use RGB 565 instead of 888 in you KIVY code ?! At the same time, here's some docs for android: https://hg.libsdl.org/SDL/file/afc8e5d1d992/docs/README-android.md there is also a script: https://hg.libsdl.org/SDL/file/afc8e5d1d992/build-scripts/androidbuild.sh not sure how much it can help but in short ... You need to have android ndk, you can build with ndk-build you need also to setup some gradle build file also. > So this commit introduce the issue ? > https://hg.libsdl.org/SDL/rev/afc8e5d1d992 I don't know if it was this commit, because ~20 commits before this one, from 12493 to 12511 mask the EGL_BAD_SURFACE error with another error. > Can you try to use RGB 565 instead of 888 in you KIVY code ?! Kivy does this right now: SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16) SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8) SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8) SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8) SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8) SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8) SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0) SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1) How should i make it use RGB 565 properly? Just change three lines? remove
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8)
add
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5)
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 6)
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5)
Also if you could bisect a little bit more to find the commit with issue also, there is a mistake:
not
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5)
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 6)
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5)
but
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5)
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5)
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 6)
(RGB == 565)
sorry:
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5)
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6)
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5)
Ok, rgb 565 works fine and doesn't crash. Ok, another try: Can you set-back ARGB8888 And comment out this line in the java file: https://hg.libsdl.org/SDL/file/5cbf6472a916/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java#l1138 commented this line, and app works fine. But SDL reports that format is 565: V/SDL (26215): pixel format RGB_565 should it be like that? btw, i am testing commit afc8e5d1d992 (first known failing one), not the tip You can also try with latest, but I believe it would be the same. Can you provide me an APK which fails so that I can try ? Can you tell which phone you use ? which android version also ? failing apk: https://drive.google.com/file/d/1G7qIJfRdAy87d2Qe_XX3oBA4HX__c6dk/view?usp=sharing the device is zte nubia z11 mini Amdroid 5.1.1 V/SDL (25270): Device: NX529J V/SDL (25270): Model: NX529J V/SDL (25270): Window size: 1080x1920 V/SDL (25270): Device size: 1080x1920 I/python (25270): [INFO ] [GL ] Using the "OpenGL ES 2" graphics system I/python (25270): [INFO ] [GL ] Backend used <sdl2> I/python (25270): [INFO ] [GL ] OpenGL version <b'OpenGL ES 3.1 V@124.0 (GIT@I041b18199e)'> I/python (25270): [INFO ] [GL ] OpenGL vendor <b'Qualcomm'> I/python (25270): [INFO ] [GL ] OpenGL renderer <b'Adreno (TM) 405'> I/python (25270): [INFO ] [GL ] OpenGL parsed version: 3, 1 I/python (25270): [INFO ] [GL ] Texture max size <16384> I/python (25270): [INFO ] [GL ] Texture max units <16> I tried but this is not clear to me to see any issue. It doesn't crash. I dont get the same log you published with "Unable to get a Window, abort." (I may need to test on an older device) I notice it gets stuck in "Loading" and I have to go to background/foreground so that it continues. Then it display "L hi 1 " Did you try to run a sample SDL2 C app ? Where can I get the sample c app? Created attachment 3842 [details]
test.c
Here's a minimal in order to create a test-case.
Modify it and try to get it crashing with the multisample enable.
I have a device where your .apk fails with:
[CRITICAL] [App ] Unable to get a Window, abort.
(Samsung S5 Android 6.0.1)
but, on this same device, If run another app, armeabi-v7a, modified with:
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1)
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16)
SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8)
SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 0)
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 2)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2)
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0)
this is working.
> I have a device where your .apk fails with: [CRITICAL] [App ] Unable to get a Window, abort. (Samsung S5 Android 6.0.1)
Look about 20 lines above the error - does it say this:
I/python ( 9712): [CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
I/python ( 9712): sdl2 - RuntimeError: b'Unable to make EGL context current (call to eglMakeCurrent failed, reporting an error of EGL_BAD_SURFACE)'
I/python ( 9712): File "/home/u1/.local/share/python-for-android/build/python-installs/paradox/kivy/core/__init__.py", line 70, in core_select_lib
I/python ( 9712): File "/home/u1/.local/share/python-for-android/build/python-installs/paradox/kivy/core/window/window_sdl2.py", line 152, in __init__
I/python ( 9712): File "/home/u1/.local/share/python-for-android/build/python-installs/paradox/kivy/core/window/__init__.py", line 969, in __init__
I/python ( 9712): File "/home/u1/.local/share/python-for-android/build/python-installs/paradox/kivy/core/window/window_sdl2.py", line 289, in create_window
I/python ( 9712): File "kivy/core/window/_window_sdl2.pyx", line 233, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
I/python ( 9712): File "kivy/core/window/_window_sdl2.pyx", line 75, in kivy.core.window._window_sdl2._WindowSDL2Storage.die
?
Yes, same log Putting Android activity lock around all the sdl calls makes this bug go away commit https://hg.libsdl.org/SDL/rev/dd9169424181 details in bug #4681 This bug is resolved with https://hg.libsdl.org/SDL/rev/dd9169424181 Closing. |