Bug 1659681 - Avoid crash in ~SharedSurace_SurfaceTexture() when GLContext is lost r=sotaro,jgilbert

Differential Revision: https://phabricator.services.mozilla.com/D88889
This commit is contained in:
James Willcox 2020-09-01 13:00:39 +00:00
parent 27494fab83
commit 665c0bd32e
2 changed files with 9 additions and 4 deletions

View File

@ -162,7 +162,8 @@ SharedSurface_SurfaceTexture::SharedSurface_SurfaceTexture(
const EGLSurface eglSurface)
: SharedSurface(desc, nullptr),
mSurface(surface),
mEglSurface(eglSurface) {}
mEglSurface(eglSurface),
mEglDisplay(GLContextEGL::Cast(desc.gl)->mEgl) {}
SharedSurface_SurfaceTexture::~SharedSurface_SurfaceTexture() {
if (mOrigEglSurface) {
@ -171,9 +172,11 @@ SharedSurface_SurfaceTexture::~SharedSurface_SurfaceTexture() {
// to the surface.
UnlockProd();
}
const auto& gle = GLContextEGL::Cast(mDesc.gl);
const auto& egl = gle->mEgl;
egl->fDestroySurface(mEglSurface);
std::shared_ptr<EglDisplay> display = mEglDisplay.lock();
if (display) {
display->fDestroySurface(mEglSurface);
}
java::SurfaceAllocator::DisposeSurface(mSurface);
}

View File

@ -13,6 +13,7 @@
#ifdef MOZ_WIDGET_ANDROID
# include "AndroidNativeWindow.h"
# include "GLLibraryEGL.h"
#endif
namespace mozilla {
@ -76,6 +77,7 @@ class SurfaceFactory_EGLImage final : public SurfaceFactory {
class SharedSurface_SurfaceTexture final : public SharedSurface {
const java::GeckoSurface::GlobalRef mSurface;
const EGLSurface mEglSurface;
const std::weak_ptr<EglDisplay> mEglDisplay;
EGLSurface mOrigEglSurface = 0;
public: