glutin icon indicating copy to clipboard operation
glutin copied to clipboard

EGL_BAD_SURFACE when swapping EGL buffers in a multithreaded context

Open elinorbgr opened this issue 9 years ago • 5 comments

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.

elinorbgr avatar May 01 '15 17:05 elinorbgr

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?

tomaka avatar Aug 27 '15 13:08 tomaka

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.

elinorbgr avatar Aug 28 '15 05:08 elinorbgr

Does anyone have more information on this?

I'm getting this error and see no solution.

meh avatar Dec 08 '16 00:12 meh

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

OptimisticPeach avatar Nov 11 '18 21:11 OptimisticPeach

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.

goddessfreya avatar Apr 08 '19 07:04 goddessfreya