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 4220

Summary: SDL_GL_CONTEXT_DEBUG_FLAG can fail silently on some Android devices
Product: SDL Reporter: Jade Macho <nuda1998>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: flibitijibibo, sezeroz
Version: HG 2.0   
Hardware: ARM   
OS: Android (All)   
Attachments: Fix disabling SDL_GL_CONTEXT_DEBUG_FLAG for possibly faulty drivers

Description Jade Macho 2018-07-30 22:50:49 UTC
Created attachment 3274 [details]
Fix disabling SDL_GL_CONTEXT_DEBUG_FLAG for possibly faulty drivers

First of all, I'm sorry if the version I selected is incorrect. I'm using this mirror, which mirrors the "default" branch by default: https://github.com/spurious/SDL-mirror

When setting the SDL_GL_CONTEXT_DEBUG_FLAG context flag on my Android device powered by an Adreno 305 GPU, the window / context creation fails silently.

libEGL itself logs
 
    E/libEGL  (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY)

to logcat, but the window / context creation doesn't "fail" (it isn't returning NULL, nor setting an error) before crashing. Specifically, in this state, invoking any GL function obtained via SDL_GL_GetProcAddress, such as glGetString, immediately causes a segmentation fault.

Possibly related and worth noting: Even though neither the GL_KHR_debug nor the EGL_KHR_debug extensions are supported by my GPU, SDL_GL_GetProcAddress("glDebugMessageControlKHR") returns a stub which logs

    E/libEGL  (22431): called unimplemented OpenGL ES API

I've thus attached a diff which removes the SDL_GL_CONTEXT_DEBUG_FLAG flag before context creation if the EGL_KHR_debug extension isn't present and if the EGL version is lower than 1.5 (which supposedly includes the extension).
The patch makes SDL lie about the created context, but from what I can tell, this seems to be a driver-related bug in the first place.
Comment 1 Sam Lantinga 2018-10-01 16:41:15 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/754cd2042e21