testsprite only shows a black screen on Android
I found these messages in the log, but I'm not sure they are relevant.
04-08 00:30:04.938 15260 15260 V SDL : surfaceChanged()
04-08 00:30:04.939 15260 15260 V SDL : Window size: 1920x1023
04-08 00:30:04.939 15260 15260 V SDL : Device size: 1920x1080
04-08 00:30:04.941 15260 15260 E libEGL : eglMakeCurrentImpl:1049 error 3002 (EGL_BAD_ACCESS)
04-08 00:30:04.941 15260 15260 E libEGL : call to OpenGL ES API with no current context (logged once per thread)
04-08 00:30:04.941 15260 15260 E libEGL : eglMakeCurrentImpl:1049 error 3002 (EGL_BAD_ACCESS)
Switching the renderer to software by passing --renderer software makes the app work, though very slow.
using software render, it's normal to be slow. not sure why there is a black screen, but logs seems the egl starts to initialize, where's runMain() log ? I would need the full adb log to see what's wrong.
(maybe more info / logs: --info renderer)
Here's a log of logcat with --info render.
log.txt
I launched SDLTestActivity through SDLEntryTestActivity.
This activity is added in #7581 to modify the arguments. Its log entries are prefixed with SDLEntry.
strange ... I tried just replacing my code, with testsprite.c and other code dependencies, and that works directly I'd say this has something to do with SDLEntryTestActivity, but in the other hand you say this runs with the software renderer.
surfaceChanged seems to be called twice .. not sure why (this may be ok). this could be, the context get lost, and now the render use a bad one.
04-08 15:58:08.247 21031 21031 V SDL : onConfigurationChanged()
04-08 15:58:08.249 2395 2517 E OpenGLRenderer: Unable to match the desired swap behavior.
04-08 15:58:08.249 21031 21049 E OpenGLRenderer: Unable to match the desired swap behavior.
04-08 15:58:08.251 21031 21031 V SDL : surfaceChanged()
using two activity, interact inbetween ...
With #7581, you can launch the SDLActivity immediately, or go though SDLEntryActivity using a shortcut (by keeping pressing on the launcher icon).
testsprite keeps showing a black screen however I launch it.
Just want to add: that I tried, and it worked :/ btw, when I go to backgroud/foreground, it became very slow. not sure what happens ... but there no synchronisation inside the app, so this is strange...
when exiting:
libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 23687 (RenderThread), pid 23667 (SDLActivity)
exiting, after bg/fg:
FORTIFY: pthread_mutex_lock called on a destroyed mutex (0x79f11bf2d0)
libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 23471 (Binder:23361_5), pid 23361 (SDLActivity)
ok. it actually not working. I was testing spritemininal ! I look later.
1/ testprite.c has some problem when it sets the logicalpresentation, that makes the black screen:
SDL_test_common.c:
if (SDL_SetRenderLogicalPresentation(state->renderers[i], state->logical_w, state->logical_h, state->logical_presentation, state->logical_scale_mode) < 0) {
SDL_Log("Couldn't set logical presentation: %s\n", SDL_GetError());
return SDL_FALSE;
}
2/ testspritemininal and lots of testapp ends the main with an exit(0). (inside the "static int quit()" function). which is bad for Android, because main() doesn't run in the main thread. (eg. the issue sigsev at the ends)
3/ background / foreground. when going to foreground, it then behaves as if presentvsync was set.
this should fix the 3/: swap interval on android: https://github.com/libsdl-org/SDL/pull/7602
2/ exits are checked here: https://github.com/libsdl-org/SDL/pull/7603
1/ the black screen happens because there are two surfaceChanged() calls, without surfaceDestroyed() in the middle. the context get lost while sdl activity is doing the orientation change. (and it's timing dependent)
Orientation in SDL/Android, isn't really reliable I think. It's better to set it in the java onCreate() side:
diff --git a/test/android/cmake/SDLTestActivity.java.cmake b/test/android/cmake/SDLTestActivity.java.cmake
index 5fc2e6099..238ffb147 100644
--- a/test/android/cmake/SDLTestActivity.java.cmake
+++ b/test/android/cmake/SDLTestActivity.java.cmake
@@ -4,6 +4,7 @@ import org.libsdl.app.SDLActivity;
import android.os.Bundle;
import android.util.Log;
+import android.content.pm.ActivityInfo;
public class SDLTestActivity extends SDLActivity {
private String[] m_arguments;
@@ -15,6 +16,7 @@ public class SDLTestActivity extends SDLActivity {
m_arguments = new String[0];
}
super.onCreate(savedInstanceState);
+ setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@Override
Is this still active?
Nope, testsprite is a good citizen now. Thanks @1bsyl !