Bug 1159262 - Don't do EGL preloading hack on ICS and higher. r=jchen, a=sledru
authorJames Willcox <snorp@snorp.net>
Tue, 28 Apr 2015 09:31:02 -0500
changeset 260341 e31ad7262160
parent 260340 dda1fe153565
child 260342 a61af55e410d
push id757
push userryanvm@gmail.com
push date2015-05-01 19:40 +0000
treeherdermozilla-release@a1efc72ea226 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjchen, sledru
bugs1159262
milestone38.0
Bug 1159262 - Don't do EGL preloading hack on ICS and higher. r=jchen, a=sledru
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;