We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3225 - Black screen when starting on Android Samsung device
Summary: Black screen when starting on Android Samsung device
Status: RESOLVED ABANDONED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.4
Hardware: ARM Android (All)
: P2 critical
Assignee: Sylvain
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-08 00:19 UTC by Davide Coppola
Modified: 2018-08-06 21:20 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Davide Coppola 2016-01-08 00:19:20 UTC
2 testers reported a black screen when starting my game on their Android device (Samsung S6).

After digging into the dev mailing list I found a message sent by a guy called Steve on the 12/06/2015 who was describing the same problem.

He suggested to uncomment the 2 limes commented out in Android_GLES_SwapWindow (src/video/android/SDL_androidgl.c), which fixes the problem for my testers as well.

Hope this helps.

P.S.
Code/issue is the same in 2.0.4 and HG 2.0, but I can only chose one version for the bug report.
Comment 1 Alex Szpakowski 2016-01-08 00:27:41 UTC
Actually the mailing list post was the opposite: In SDL 2.0.3 the lines were uncommented and the poster had the problem. When they commented the lines out, the problem went away. SDL 2.0.4 has the lines commented out.

It's also worth mentioning that having those lines uncommented will *heavily* impact performance in a negative way, on many devices.
Comment 2 Davide Coppola 2016-01-08 00:39:55 UTC
Right, I misread the original message (long day here...).

What am I supposed to do then?
Comment 3 Sylvain 2016-01-08 08:20:50 UTC
1/ did you update all you android tools, sdk, ndk and java files ?

2/ I'd be curious to see if your users get the same problem with *my* games.

3/ Something that can be tried (because there was a strange issue with Samsung S3 a while ago), is to comment out the "egl config" algorithm:

in SDL_egl.c, in the function "SDL_EGL_ChooseConfig" :
let the call to "eglChooseConfig" select the first config, that is "config[0]".

make something equivalent to 
https://hg.libsdl.org/SDL/file/ac4ce59c40e7/src/video/SDL_egl.c
lines 253 to 259
Comment 4 Gab 2016-07-13 11:44:10 UTC
We had the same issue in a app uploaded to the playstore with Samsung S6 Edge devices.

A few months later some users reported the black screen issues got fixed by updating the device to the latest android software. Probably Samsung fixed that issue?
Comment 5 Sylvain 2016-07-13 20:35:34 UTC
Facing also the same issue. A black screen on Samsung s6 (model is sm-g920f zeroflte, is it normal or edge ?).

I don't have the device, only got the information from my Pre Launch Test report.

I am using the SDL2 head trunk and I tried various fixes without real success.

@Gab, do you have any android version number where it fails or not? Do you use side libraries/jar package?
Is your app landscape or portrait?
Comment 6 Sylvain 2016-07-17 19:12:35 UTC
That may be was a bug on the S6 video driver.

http://git.quintin.ninja/mjones/Dolphin/commit/01db003779ff7240efa40842ac7d44e70a5edb0e

 ------
 Bug: ARM Mali managed to break disabling vsync
 Affected Devices: Mali
 Started Version: r5p0-rev2
 Ended Version: -1
 If we disable vsync with eglSwapInterval(dpy, 0) then the screen will stop showing new updates after a handful of swaps.
 This was noticed on a Samsung Galaxy S6 with its Android 5.1.1 update.
 The default Android 5.0 image didn't encounter this issue.
 We can't actually detect what the driver version is on Android, so until the driver version lands that displays the version in
 the GL_VERSION string, we will have to force vsync to be enabled at all times.
 --------


Indeed, using the flag SDL_RENDERER_PRESENTVSYNC seems to fix the issue.
Comment 7 Vedran Klanac 2017-02-16 08:53:17 UTC
I'm having this issue as well. I use SDL 2.0.5 on Android.
Device I use is Samsung Galaxy Alpha - SM-G850F.

Now, what is reported here to be black screen, I figured it's actually a clear color.
I manage to change clear color and see different color but no solid fill triangle or textured triangle rendering whatsoever.

I'm not using SDL Renderer but directly Open GL.

Android JNI properly initializes, SDL window is created, SDL context is created, audio is initialized and working, input is initialized and working.

I'm using default SDLActivity.java provided with SDL 2.0.5 without any modifications, as is.


I have been following other threads related to this issue and I experimented with EGL configurations.
I do get proper configuration which supports proper pixel format and other parameters.
Here's the dump of EGL flags for the config I get (ret value is just confirmation if query call was success).

EGL_ALPHA_SIZE = 8 (ret = 1)
EGL_ALPHA_MASK_SIZE = 8 (ret = 1)
EGL_BIND_TO_TEXTURE_RGB = 0 (ret = 1)
EGL_BIND_TO_TEXTURE_RGBA = 1 (ret = 1)
EGL_BUFFER_SIZE = 32 (ret = 1)
EGL_COLOR_BUFFER_TYPE = 12430 (ret = 1)
EGL_CONFIG_CAVEAT = 12344 (ret = 1)
EGL_CONFIG_ID = 2 (ret = 1)
EGL_CONFORMANT = 69 (ret = 1)
EGL_DEPTH_SIZE = 24 (ret = 1)
EGL_GREEN_SIZE = 8 (ret = 1)
EGL_LEVEL = 0 (ret = 1)
EGL_LUMINANCE_SIZE = 0 (ret = 1)
EGL_MAX_PBUFFER_WIDTH = 8192 (ret = 1)
EGL_MAX_PBUFFER_HEIGHT = 8192 (ret = 1)
EGL_MAX_PBUFFER_PIXELS = 67108864 (ret = 1)
EGL_MAX_SWAP_INTERVAL = 1 (ret = 1)
EGL_MIN_SWAP_INTERVAL = 0 (ret = 1)
EGL_NATIVE_RENDERABLE = 0 (ret = 1)
EGL_NATIVE_VISUAL_ID = 1 (ret = 1)
EGL_NATIVE_VISUAL_TYPE = 4 (ret = 1)
EGL_RED_SIZE = 8 (ret = 1)
EGL_RENDERABLE_TYPE = 69 (ret = 1)
EGL_SAMPLE_BUFFERS = 0 (ret = 1)
EGL_SAMPLES = 0 (ret = 1)
EGL_STENCIL_SIZE = 0 (ret = 1)
EGL_SURFACE_TYPE = 1029 (ret = 1)
EGL_TRANSPARENT_TYPE = 12344 (ret = 1)
EGL_TRANSPARENT_RED_VALUE = 0 (ret = 1)
EGL_TRANSPARENT_GREEN_VALUE = 0 (ret = 1)
EGL_TRANSPARENT_BLUE_VALUE = 0 (ret = 1)

In general we use PNG textures in our games which are RGBA and 32-bit. What I can see from the config above, it should support it without a problem.

If there's anyone out there with successful strategy on resolving this, any suggestion is welcome.
Comment 8 Vedran Klanac 2017-02-16 14:31:01 UTC
As an addition, we just got the same result, in our case red screen on following devices:
Samsung Galaxy S7 (Android 6.0.1)
HTC Nexus 9 (Android 5.1.1)
Sony Xperia Z4 (Android 6.0.1)
Comment 9 Sylvain 2017-02-16 14:36:47 UTC
black screen -> try to set the SDL_RENDERER_PRESENTVSYNC flag
red screen -> play with egl config see bug #2291
Comment 10 Vedran Klanac 2017-02-16 15:21:24 UTC
(In reply to Sylvain from comment #9)
> black screen -> try to set the SDL_RENDERER_PRESENTVSYNC flag
> red screen -> play with egl config see bug #2291

As I understand this flag is used when you use SDL_Renderer right? Or I'm missing something?
Well, I'm not using SDL_Renderer at all in our code.
I use direct OpenGL commands.

When it comes to bug #2291, yes I know about that thread.
I was dealing with ideas what was communicated there and no effect. 
Not to mention that, thread related to bug #2291 talks about lot of "assumptions" without real solution for the case.

That's why posted here because it seems this is not fixed yet and let's see if we can resolve it in clear way.

So, let's summarize it:
- using SDL2 2.0.5
- using provided SDLActivity.java as is

- setting following flags before creating SDL Window:

SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 8 );
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);

- create SDL window
- I get EGL configuration with proper pixel format (ref: dump is in my post above).
- try to render simple solid filled triangle in yellow color

Result = red screen on all the devices mentioned above in the post, not just on Samsung Galaxy.

I'm aware that a specific detail plays a key role here, but I'm not seeing what it is.
Comment 11 Sylvain 2017-02-16 20:53:26 UTC
- PRESENT_VSYNC is a call to eglSwapInterval 0 or 1 I think.

- can you reduce to a basic test case ? and run it on a linux pc to see what happens ?
Comment 12 Vedran Klanac 2017-02-16 21:12:43 UTC
(In reply to Sylvain from comment #11)
> - PRESENT_VSYNC is a call to eglSwapInterval 0 or 1 I think.
> 
> - can you reduce to a basic test case ? and run it on a linux pc to see what
> happens ?

I can't test on linux PC. I can do win, iOS, Mac and Android.

However I did try setting swap interval on Android to 0 and 1 after creating SDL window and before first swap. No effect.
Comment 13 Ryan C. Gordon 2018-08-06 21:20:23 UTC
Hello, and sorry if you're getting dozens of copies of this message by email.

We are closing out bugs that appear to be abandoned in some form. This can happen for lots of reasons: we couldn't reproduce it, conversation faded out, the bug was noted as fixed in a comment but we forgot to mark it resolved, the report is good but the fix is impractical, we fixed it a long time ago without realizing there was an associated report, etc.

Individually, any of these bugs might have a better resolution (such as WONTFIX or WORKSFORME or INVALID) but we've added a new resolution of ABANDONED to make this easily searchable and make it clear that it's not necessarily unreasonable to revive a given bug report.

So if this bug is still a going concern and you feel it should still be open: please feel free to reopen it! But unless you respond, we'd like to consider these bugs closed, as many of them are several years old and overwhelming our ability to prioritize recent issues.

(please note that hundred of bug reports were sorted through here, so we apologize for any human error. Just reopen the bug in that case!)

Thanks,
--ryan.