Bug 1159262 - Don't do EGL preloading hack on ICS and higher r=jchen
authorJames Willcox <snorp@snorp.net>
Tue, 28 Apr 2015 09:31:02 -0500
changeset 271445 fd53978dc47e553198d0948299fe3e43d2a4d79c
parent 271444 be5b399dc1a02616d7775d491a8ea64c9a507eca
child 271446 aaf0522888138e945be618750225d65c1ca41dd4
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen
bugs1159262
milestone40.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 1159262 - Don't do EGL preloading hack on ICS and higher r=jchen
mobile/android/base/gfx/GLController.java
--- a/mobile/android/base/gfx/GLController.java
+++ b/mobile/android/base/gfx/GLController.java
@@ -1,15 +1,16 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.gfx;
 
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.GeckoEvent;
 import org.mozilla.gecko.GeckoThread;
 import org.mozilla.gecko.mozglue.generatorannotations.WrapElementForJNI;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.util.Log;
 
@@ -107,18 +108,22 @@ public class GLController {
         EGL10.EGL_GREEN_SIZE, 8,
         EGL10.EGL_BLUE_SIZE, 8,
         EGL10.EGL_SURFACE_TYPE, EGL10.EGL_WINDOW_BIT,
         EGL10.EGL_RENDERABLE_TYPE, LOCAL_EGL_OPENGL_ES2_BIT,
         EGL10.EGL_NONE
     };
 
     private GLController() {
-        mEGLPreloadingThread = new EGLPreloadingThread();
-        mEGLPreloadingThread.start();
+        if (AppConstants.Versions.preICS) {
+            mEGLPreloadingThread = new EGLPreloadingThread();
+            mEGLPreloadingThread.start();
+        } else {
+            mEGLPreloadingThread = null;
+        }
     }
 
     static GLController getInstance(LayerView view) {
         if (sInstance == null) {
             sInstance = new GLController();
         }
         sInstance.mView = view;
         return sInstance;
@@ -206,42 +211,46 @@ public class GLController {
             return;
         }
 
         // This join() should not be necessary, but makes this code a bit easier to think about.
         // The EGLPreloadingThread should long be done by now, and even if it's not,
         // it shouldn't be a problem to be initializing EGL from two different threads.
         // Still, having this join() here means that we don't have to wonder about what
         // kind of caveats might exist with EGL initialization reentrancy on various drivers.
-        try {
-            mEGLPreloadingThread.join();
-        } catch (InterruptedException e) {
-            Log.w(LOGTAG, "EGLPreloadingThread interrupted", e);
+        if (mEGLPreloadingThread != null) {
+            try {
+                mEGLPreloadingThread.join();
+            } catch (InterruptedException e) {
+                Log.w(LOGTAG, "EGLPreloadingThread interrupted", e);
+            }
         }
 
         mEGL = (EGL10)EGLContext.getEGL();
 
         mEGLDisplay = mEGL.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
         if (mEGLDisplay == EGL10.EGL_NO_DISPLAY) {
             Log.w(LOGTAG, "Can't get EGL display!");
             return;
         }
 
-        // while calling eglInitialize here should not be necessary as it was already called
-        // by the EGLPreloadingThread, it really doesn't cost much to call it again here,
-        // and makes this code easier to think about: EGLPreloadingThread is only a
-        // preloading optimization, not something we rely on for anything else.
-        //
-        // Also note that while calling eglInitialize isn't necessary on Android 4.x
-        // (at least Android's HardwareRenderer does it for us already), it is necessary
-        // on Android 2.x.
-        int[] returnedVersion = new int[2];
-        if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) {
-            Log.w(LOGTAG, "eglInitialize failed");
-            return;
+        if (AppConstants.Versions.preICS) {
+            // while calling eglInitialize here should not be necessary as it was already called
+            // by the EGLPreloadingThread, it really doesn't cost much to call it again here,
+            // and makes this code easier to think about: EGLPreloadingThread is only a
+            // preloading optimization, not something we rely on for anything else.
+            //
+            // Also note that while calling eglInitialize isn't necessary on Android 4.x
+            // (at least Android's HardwareRenderer does it for us already), it is necessary
+            // on Android 2.x.
+            int[] returnedVersion = new int[2];
+            if (!mEGL.eglInitialize(mEGLDisplay, returnedVersion)) {
+                Log.w(LOGTAG, "eglInitialize failed");
+                return;
+            }
         }
 
         mEGLConfig = chooseConfig();
     }
 
     private EGLConfig chooseConfig() {
         int[] desiredConfig;
         int rSize, gSize, bSize;