From bfdfd329b23704e23c73873d70b9231ef6a2c939 Mon Sep 17 00:00:00 2001 From: Martin Stransky Date: Mon, 13 Jun 2022 16:36:43 +0200 Subject: Fix WebGL mem leaks (mzbz#1773968) --- D149135.diff | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 D149135.diff (limited to 'D149135.diff') diff --git a/D149135.diff b/D149135.diff new file mode 100644 index 0000000..6e93f2b --- /dev/null +++ b/D149135.diff @@ -0,0 +1,80 @@ +diff --git a/widget/gtk/DMABufSurface.cpp b/widget/gtk/DMABufSurface.cpp +--- a/widget/gtk/DMABufSurface.cpp ++++ b/widget/gtk/DMABufSurface.cpp +@@ -642,11 +642,11 @@ + + void DMABufSurfaceRGBA::ReleaseTextures() { + LOGDMABUF(("DMABufSurfaceRGBA::ReleaseTextures() UID %d\n", mUID)); + FenceDelete(); + +- if (!mTexture) { ++ if (!mTexture && mEGLImage == LOCAL_EGL_NO_IMAGE) { + return; + } + + if (!mGL) { + #ifdef NIGHTLY +@@ -663,17 +663,17 @@ + const auto& egl = gle->mEgl; + + if (mTexture && mGL->MakeCurrent()) { + mGL->fDeleteTextures(1, &mTexture); + mTexture = 0; +- mGL = nullptr; + } + + if (mEGLImage != LOCAL_EGL_NO_IMAGE) { + egl->fDestroyImage(mEGLImage); + mEGLImage = LOCAL_EGL_NO_IMAGE; + } ++ mGL = nullptr; + } + + void DMABufSurfaceRGBA::ReleaseSurface() { + MOZ_ASSERT(!IsMapped(), "We can't release mapped buffer!"); + +@@ -1325,11 +1325,11 @@ + + FenceDelete(); + + bool textureActive = false; + for (int i = 0; i < mBufferPlaneCount; i++) { +- if (mTexture[i]) { ++ if (mTexture[i] || mEGLImage[i] != LOCAL_EGL_NO_IMAGE) { + textureActive = true; + break; + } + } + +@@ -1346,18 +1346,23 @@ + "leaking textures!"); + return; + #endif + } + +- if (textureActive && mGL->MakeCurrent()) { +- mGL->fDeleteTextures(DMABUF_BUFFER_PLANES, mTexture); +- for (int i = 0; i < DMABUF_BUFFER_PLANES; i++) { +- mTexture[i] = 0; +- } +- ReleaseEGLImages(mGL); +- mGL = nullptr; ++ if (!mGL->MakeCurrent()) { ++ NS_WARNING( ++ "DMABufSurfaceYUV::ReleaseTextures(): Failed to create GL context " ++ "current. We're leaking textures!"); ++ return; + } ++ ++ mGL->fDeleteTextures(DMABUF_BUFFER_PLANES, mTexture); ++ for (int i = 0; i < DMABUF_BUFFER_PLANES; i++) { ++ mTexture[i] = 0; ++ } ++ ReleaseEGLImages(mGL); ++ mGL = nullptr; + } + + bool DMABufSurfaceYUV::VerifyTextureCreation() { + LOGDMABUF(("DMABufSurfaceYUV::VerifyTextureCreation() UID %d", mUID)); + + -- cgit