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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ firefox.spec | 7 +++++- 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 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)); + + diff --git a/firefox.spec b/firefox.spec index 24fce88..1f412f8 100644 --- a/firefox.spec +++ b/firefox.spec @@ -163,7 +163,7 @@ ExcludeArch: aarch64 Summary: Mozilla Firefox Web browser Name: firefox Version: 101.0.1 -Release: 1%{?pre_tag}%{?dist} +Release: 2%{?pre_tag}%{?dist} URL: https://www.mozilla.org/firefox/ License: MPLv1.1 or GPLv2+ or LGPLv2+ Source0: https://archive.mozilla.org/pub/firefox/releases/%{version}%{?pre_version}/source/firefox-%{version}%{?pre_version}.source.tar.xz @@ -267,6 +267,7 @@ Patch435: D146275.diff Patch440: D147635.diff Patch441: D147636.diff Patch442: D147637.diff +Patch443: D149135.diff # PGO/LTO patches Patch600: pgo.patch @@ -532,6 +533,7 @@ This package contains results of tests executed during build. %patch440 -p1 -b .D147635.diff %patch441 -p1 -b .D147636.diff %patch442 -p1 -b .D147637.diff +%patch443 -p1 -b .D149135.diff # More VA-API fixes %patch422 -p1 -b .D147720.diff @@ -1108,6 +1110,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : #--------------------------------------------------------------------- %changelog +* Mon Jun 13 2022 Martin Stransky - 101.0.1-2 +- Fix WebGL mem leaks (mzbz#1773968) + * Thu Jun 9 2022 Martin Stransky - 101.0.1-1 - Updated to 101.0.1 - More VA-API sandbox fixes (mzbz#1769182) -- cgit