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

[Android] Calling SDL_VideoInit after SDL_Init with no parameters crashes the app #1028

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.0
Reported for operating system, platform: Android (All), ARM

Comments on the original bug report:

On 2013-08-15 14:14:38 +0000, Joe LeVeque wrote:

I'm trying to get my app to run in landscape mode only on Android. I tried setting the orientation in AndroidManifest.xml to no avail, so instead I added the following java code in onCreate():

// Force landscape orientation
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

This does force the orientation to rotate when the app starts, and appears to prevent the screen from rotating while the app is running - that's great. If my phone is already in landscape mode when I launch the app, the app runs fine. However, if the phone is in portrait mode when the app is launched, the app will start, but will be killed after a frame or two and I see the following in the logcat:

E/libEGL(3988): call to OpenGL ES API with no current context (logged once per thread)
D/dalvikvm(3988): threadid=15: thread exiting, not yet detached (count=0)
I/WindowState(699): WIN DEATH: Window{41ca3af8 u0 SurfaceView}
I/ActivityManager(699): Process (pid 3988) has died.
W/ActivityManager(699): Force removing ActivityRecord{41e487b0 u0 }: app died, no saved state
I/WindowState(699): WIN DEATH: Window{41c8b550 u0 }

So, it appears as though the OpenGL context is somehow getting trashed even though the context isn't getting created until after the rotation has been done. This appears to be a bug in SDL2.

No evidence of a crash, and no stack trace is generated. It seems as though the app is somehow exiting normally. I'm willing to help find and fix this issue.

On 2013-08-15 21:31:04 +0000, Joe LeVeque wrote:

Update:

This seems to be related to calling SDL_Init() without SDL_INIT_VIDEO, and subsequently calling SDL_VideoInit(NULL) at a point later in code. I replaced the above with SDL_Init(SDL_INIT_EVERYTHING), and the problem disappears.

On 2013-08-15 22:20:15 +0000, Gabriel Jacobo wrote:

There's a few changes coming in the EGL management code on Android (see # 2037) that will hopefully reduce the crazyness of SDL on Android. Let's revisit this after that patch lands.

On 2013-11-06 14:25:38 +0000, Gabriel Jacobo wrote:

Are you still seeing this issue?

On 2013-11-06 19:11:46 +0000, Joe LeVeque wrote:

Since I found that calling SDL_Init(SDL_INIT_EVERYTHING) works without issue, I had been using that in my code. However, I just switched my code back to call SDL_Init() without SDL_INIT_VIDEO, and then call SDL_VideoInit(NULL) later, and unfortunately, the problem reappeared with the exact same symptoms and logcat output.

On 2017-08-23 13:55:25 +0000, Sylvain wrote:

I tried and it seems to be working.

( setting landscape in onCreate(), starting in portrait, using SDL_VideoInit(NULL))

On 2017-09-04 20:41:26 +0000, Sam Lantinga wrote:

This seems to be fixed in the latest SDL snapshot:
http://www.libsdl.org/tmp/SDL-2.0.zip

Please reopen this bug if you can reproduce this with the same output.

Thanks!

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

1 participant