Bug 1474847 - Fix GeckoSurfaceTexture not correctly removed from container when released: r=snorp,rbarker
authorImanol Fernandez <imanol@mozilla.com>
Mon, 27 Aug 2018 15:15:21 +0000
changeset 488609 ca0f02aa22ea8a12765eeed8a7f337c3b5b1be2e
parent 488608 be4fd8ee7afd98b8e8f1cbffd2fc634fa5fe49a1
child 488610 41ccbc9bc2b281179ee435ffb4c6141062f109b1
push id9734
push usershindli@mozilla.com
push dateThu, 30 Aug 2018 12:18:07 +0000
treeherdermozilla-beta@71c71ab3afae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, rbarker
bugs1474847
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1474847 - Fix GeckoSurfaceTexture not correctly removed from container when released: r=snorp,rbarker When entering and exiting immersive mode multiple time (~30) the WebGL context can be lost. This is caused because GeckoSurfaceTexture things there are more than 200 textures created. Differential Revision: https://phabricator.services.mozilla.com/D4236
mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoSurfaceTexture.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoSurfaceTexture.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/gfx/GeckoSurfaceTexture.java
@@ -114,16 +114,28 @@ import org.mozilla.gecko.annotation.Wrap
                 mListener.onUpdateTexImage();
             }
         } catch (Exception e) {
             Log.w(LOGTAG, "updateTexImage() failed", e);
         }
     }
 
     @Override
+    public synchronized void release() {
+        try {
+            super.release();
+            synchronized (sSurfaceTextures) {
+                sSurfaceTextures.remove(mHandle);
+            }
+        } catch (Exception e) {
+            Log.w(LOGTAG, "release() failed", e);
+        }
+    }
+
+    @Override
     @WrapForJNI
     public synchronized void releaseTexImage() {
         if (!mIsSingleBuffer) {
             return;
         }
 
         try {
             super.releaseTexImage();
@@ -180,20 +192,16 @@ import org.mozilla.gecko.annotation.Wrap
         }
 
         if (list == null) {
             return;
         }
 
         for (GeckoSurfaceTexture tex : list) {
             try {
-                synchronized (sSurfaceTextures) {
-                    sSurfaceTextures.remove(tex.mHandle);
-                }
-
                 if (tex.isSingleBuffer()) {
                    tex.releaseTexImage();
                 }
 
                 tex.detachFromGLContext();
                 tex.release();
 
                 // We need to manually call finalize here, otherwise we can run out