glutin
glutin copied to clipboard
EGL_BAD_SURFACE when swapping EGL buffers in a multithreaded context
I found this while working on wayland, but it also affects X11 (an maybe other platforms, could not test)
Steps to reproduce:
- Apply this commit https://github.com/vberger/glutin/commit/8f87123551c76c54ccab91bfb15e43a3fb074030 which forces the use of EGL with X11 and reduces the multiwindow example to a single thread
- Run the multiwindow example
for me it results in:
OpenGL version 3.0 Mesa 10.3.7
thread '<unnamed>' panicked at 'eglSwapBuffers failed', src/api/egl/mod.rs:191
running with EGL_LOG_LEVEL=debug
gives more information:
libEGL debug: EGL user error 0x300d (EGL_BAD_SURFACE) in eglSwapBuffers
I don't know if it's a glutin bug or a bug from my system (mesa bug ?), would probably be good if it could be tested on different setups to figure this out.
After some debugging, it seems that eglGetCurrentContext
returns null even when called right after calling eglMakeCurrent
with a non-null context.
The call to eglMakeCurrent
in question returns EGL_TRUE
and eglGetError
returns EGL_SUCCESS
.
Solution: call eglCurrentContext
manually after each eglMakeCurrent
to see if the make current operation worked?
It would appear this is actually a bug in Mesa's EGL implementation, I cannot reproduce it using Nvidia's libEGL.so
Cannot test on AMD though.
Does anyone have more information on this?
I'm getting this error and see no solution.
Ah, I found a solution for the time being:
When matching the android_glue::Event
and get a Event::LostFocus
set a flag to false to signal to not draw, and then when drawing, only draw when the flag is true, and then when Event::GainedFocus
is reached, set the flag to true.
Edit - Oops, I forgot that this wasn't an android-only repo. Well, it works for android
Can people still repo this? Can I get more more info? eglinfo && glxinfo && glinfo && lspci
if on linux please. I can't repo this, and I'm using AMD and mesa.