diff --git a/gfx/webrender_bindings/RenderCompositorEGL.cpp b/gfx/webrender_bindings/RenderCompositorEGL.cpp index e41755bf54d0..e40a56683229 100644 --- a/gfx/webrender_bindings/RenderCompositorEGL.cpp +++ b/gfx/webrender_bindings/RenderCompositorEGL.cpp @@ -59,16 +59,13 @@ RenderCompositorEGL::~RenderCompositorEGL() { DestroyEGLSurface(); } bool RenderCompositorEGL::BeginFrame() { #ifdef MOZ_WAYLAND - if (mWidget->AsX11() && - mWidget->AsX11()->WaylandRequestsUpdatingEGLSurface()) { - // Destroy EGLSurface if it exists. + bool newSurface = + mWidget->AsX11() && mWidget->AsX11()->WaylandRequestsUpdatingEGLSurface(); + if (newSurface) { + // Destroy EGLSurface if it exists and create a new one. We will set the + // swap interval after MakeCurrent() has been called. DestroyEGLSurface(); mEGLSurface = CreateEGLSurface(); - if (mEGLSurface) { - const auto* egl = gl::GLLibraryEGL::Get(); - // Make eglSwapBuffers() non-blocking on wayland - egl->fSwapInterval(gl::EGL_DISPLAY(), 0); - } } #endif if (!MakeCurrent()) { @@ -76,6 +73,18 @@ bool RenderCompositorEGL::BeginFrame() { return false; } +#ifdef MOZ_WAYLAND + if (newSurface) { + // We have a new EGL surface, which on wayland needs to be configured for + // non-blocking buffer swaps. We need MakeCurrent() to set our current EGL + // context before we call eglSwapInterval, which is why we do it here rather + // than where the surface was created. + const auto* egl = gl::GLLibraryEGL::Get(); + // Make eglSwapBuffers() non-blocking on wayland. + egl->fSwapInterval(gl::EGL_DISPLAY(), 0); + } +#endif + #ifdef MOZ_WIDGET_ANDROID java::GeckoSurfaceTexture::DestroyUnused((int64_t)gl()); #endif