Backed out changesets 4fee6e1f1ad2 and f5db0dae1434 (bug 1075644) for Android 2.3 robocop failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 06 Oct 2014 15:47:30 -0400
changeset 232279 8f1758ce53f05216f35ab9720d4db3782623225e
parent 232278 e17d2378aa66400f93ac37325c35cfd23d941636
child 232280 f4953072c20f75a7257538f990a232abfadc4354
push id4187
push userbhearsum@mozilla.com
push dateFri, 28 Nov 2014 15:29:12 +0000
treeherdermozilla-beta@f23cc6a30c11 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1075644
milestone35.0a1
backs out4fee6e1f1ad29c5a711ce3ab521b17fdd1539e49
f5db0dae14347be0f0c6c266e08ba8600f9714e8
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
Backed out changesets 4fee6e1f1ad2 and f5db0dae1434 (bug 1075644) for Android 2.3 robocop failures. CLOSED TREE
mobile/android/base/GeckoApp.java
mobile/android/base/GeckoThread.java
mobile/android/base/home/TopSitesPanel.java
mobile/android/base/util/ThreadUtils.java
--- a/mobile/android/base/GeckoApp.java
+++ b/mobile/android/base/GeckoApp.java
@@ -1172,25 +1172,34 @@ public abstract class GeckoApp
             }
         });
 
         // Workaround for <http://code.google.com/p/android/issues/detail?id=20915>.
         try {
             Class.forName("android.os.AsyncTask");
         } catch (ClassNotFoundException e) {}
 
+        MemoryMonitor.getInstance().init(getApplicationContext());
+
         // GeckoAppShell is tightly coupled to us, rather than
         // the app context, because various parts of Fennec (e.g.,
         // GeckoScreenOrientation) use GAS to access the Activity in
         // the guise of fetching a Context.
         // When that's fixed, `this` can change to
         // `(GeckoApplication) getApplication()` here.
         GeckoAppShell.setContextGetter(this);
         GeckoAppShell.setGeckoInterface(this);
 
+        Tabs.getInstance().attachToContext(this);
+        try {
+            Favicons.initializeWithContext(this);
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Exception starting favicon cache. Corrupt resources?", e);
+        }
+
         // Did the OS locale change while we were backgrounded? If so,
         // we need to die so that Gecko will re-init add-ons that touch
         // the UI.
         // This is using a sledgehammer to crack a nut, but it'll do for
         // now.
         if (BrowserLocaleManager.getInstance().systemLocaleDidChange()) {
             Log.i(LOGTAG, "System locale changed. Restarting.");
             doRestart();
@@ -1224,30 +1233,16 @@ public abstract class GeckoApp
                 @Override
                 public void run() {
                     GeckoThread.setLaunchState(GeckoThread.LaunchState.Launched);
                     GeckoThread.createAndStart();
                 }
             }, 1000 * 5 /* 5 seconds */);
         }
 
-        // Heavy load on the Gecko thread can slow down the time it takes for UI to appear on
-        // single-core devices. By minimizing the Gecko thread priority, we ensure that the UI
-        // appears quickly. The priority is reset to normal once thumbnails are loaded.
-        ThreadUtils.reduceGeckoPriority();
-
-        MemoryMonitor.getInstance().init(getApplicationContext());
-
-        Tabs.getInstance().attachToContext(this);
-        try {
-            Favicons.initializeWithContext(this);
-        } catch (Exception e) {
-            Log.e(LOGTAG, "Exception starting favicon cache. Corrupt resources?", e);
-        }
-
         Bundle stateBundle = getIntent().getBundleExtra(EXTRA_STATE_BUNDLE);
         if (stateBundle != null) {
             // Use the state bundle if it was given as an intent extra. This is
             // only intended to be used internally via Robocop, so a boolean
             // is read from a private shared pref to prevent other apps from
             // injecting states.
             final SharedPreferences prefs = getSharedPreferences();
             if (prefs.getBoolean(PREFS_ALLOW_STATE_BUNDLE, false)) {
@@ -1605,20 +1600,16 @@ public abstract class GeckoApp
             GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Viewport:Flush", null));
         }
 
         if (ACTION_ALERT_CALLBACK.equals(action)) {
             processAlertCallback(intent);
         } else if (NotificationHelper.HELPER_BROADCAST_ACTION.equals(action)) {
             NotificationHelper.getInstance(getApplicationContext()).handleNotificationIntent(intent);
         }
-
-        // Reset Gecko to normal priority. We may reduce the
-        // priority again later, e.g. for loading thumbnails.
-        ThreadUtils.resetGeckoPriority();
     }
 
     private String restoreSessionTabs(final boolean isExternalURL) throws SessionRestoreException {
         try {
             String sessionString = getProfile().readSessionFile(false);
             if (sessionString == null) {
                 throw new SessionRestoreException("Could not read from session file");
             }
--- a/mobile/android/base/GeckoThread.java
+++ b/mobile/android/base/GeckoThread.java
@@ -46,17 +46,16 @@ public class GeckoThread extends Thread 
     private final String mAction;
     private final String mUri;
 
     public static boolean ensureInit() {
         ThreadUtils.assertOnUiThread();
         if (isCreated())
             return false;
         sGeckoThread = new GeckoThread(sArgs, sAction, sUri);
-        ThreadUtils.sGeckoThread = sGeckoThread;
         return true;
     }
 
     public static String sArgs;
     public static String sAction;
     public static String sUri;
 
     public static void setArgs(String args) {
@@ -160,16 +159,17 @@ public class GeckoThread extends Thread 
         }
 
         return (args != null ? args : "") + profileArg + guestArg;
     }
 
     @Override
     public void run() {
         Looper.prepare();
+        ThreadUtils.sGeckoThread = this;
         ThreadUtils.sGeckoHandler = new Handler();
         ThreadUtils.sGeckoQueue = Looper.myQueue();
 
         String path = initGeckoEnvironment();
 
         // This can only happen after the call to initGeckoEnvironment
         // above, because otherwise the JNI code hasn't been loaded yet.
         ThreadUtils.postToUiThread(new Runnable() {
--- a/mobile/android/base/home/TopSitesPanel.java
+++ b/mobile/android/base/home/TopSitesPanel.java
@@ -93,16 +93,19 @@ public class TopSitesPanel extends HomeF
     private ThumbnailsLoaderCallbacks mThumbnailsLoaderCallbacks;
 
     // Listener for editing pinned sites.
     private EditPinnedSiteListener mEditPinnedSiteListener;
 
     // Max number of entries shown in the grid from the cursor.
     private int mMaxGridEntries;
 
+    // Time in ms until the Gecko thread is reset to normal priority.
+    private static final long PRIORITY_RESET_TIMEOUT = 10000;
+
     public static TopSitesPanel newInstance() {
         return new TopSitesPanel();
     }
 
     private static boolean logDebug = Log.isLoggable(LOGTAG, Log.DEBUG);
     private static boolean logVerbose = Log.isLoggable(LOGTAG, Log.VERBOSE);
 
     private static void debug(final String message) {
@@ -339,17 +342,17 @@ public class TopSitesPanel extends HomeF
         getLoaderManager().initLoader(LOADER_ID_TOP_SITES, null, mCursorLoaderCallbacks);
 
         // Since this is the primary fragment that loads whenever about:home is
         // visited, we want to load it as quickly as possible. Heavy load on
         // the Gecko thread can slow down the time it takes for thumbnails to
         // appear, especially during startup (bug 897162). By minimizing the
         // Gecko thread priority, we ensure that the UI appears quickly. The
         // priority is reset to normal once thumbnails are loaded.
-        ThreadUtils.reduceGeckoPriority();
+        ThreadUtils.reduceGeckoPriority(PRIORITY_RESET_TIMEOUT);
     }
 
     /**
      * Listener for editing pinned sites.
      */
     private class EditPinnedSiteListener implements OnEditPinnedSiteListener,
                                                     OnSiteSelectedListener {
         // Tag for the PinSiteDialog fragment.
--- a/mobile/android/base/util/ThreadUtils.java
+++ b/mobile/android/base/util/ThreadUtils.java
@@ -12,19 +12,16 @@ import java.util.Map;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.MessageQueue;
 import android.util.Log;
 
 public final class ThreadUtils {
     private static final String LOGTAG = "ThreadUtils";
 
-    // Time in ms until the Gecko thread is reset to normal priority.
-    private static final long PRIORITY_RESET_TIMEOUT = 10000;
-
     /**
      * Controls the action taken when a method like
      * {@link ThreadUtils#assertOnUiThread(AssertBehavior)} detects a problem.
      */
     public static enum AssertBehavior {
         NONE,
         THROW,
     }
@@ -207,28 +204,30 @@ public final class ThreadUtils {
     }
 
     /**
      * Reduces the priority of the Gecko thread, allowing other operations
      * (such as those related to the UI and database) to take precedence.
      *
      * Note that there are no guards in place to prevent multiple calls
      * to this method from conflicting with each other.
+     *
+     * @param timeout Timeout in ms after which the priority will be reset
      */
-    public static void reduceGeckoPriority() {
+    public static void reduceGeckoPriority(long timeout) {
         if (Runtime.getRuntime().availableProcessors() > 1) {
             // Don't reduce priority for multicore devices. We use availableProcessors()
             // for its fast performance. It may give false negatives (i.e. multicore
             // detected as single-core), but we can tolerate this behavior.
             return;
         }
         if (!sIsGeckoPriorityReduced && sGeckoThread != null) {
             sIsGeckoPriorityReduced = true;
             sGeckoThread.setPriority(Thread.MIN_PRIORITY);
-            getUiHandler().postDelayed(sPriorityResetRunnable, PRIORITY_RESET_TIMEOUT);
+            getUiHandler().postDelayed(sPriorityResetRunnable, timeout);
         }
     }
 
     /**
      * Resets the priority of a thread whose priority has been reduced
      * by reduceGeckoPriority.
      */
     public static void resetGeckoPriority() {