Bug 1278581 - Part 4 - Ensure the progress bar doesn't get stuck after displaying the error page. r?esawin draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Thu, 22 Mar 2018 21:51:33 +0100
changeset 775266 a8bcb7c80429b508014a5781bb5375a19e54347d
parent 775265 c1bb1f245f7578f260eeab230a479539c01c5ecc
child 775434 9730cc10fb4c6be516c9aac997e2edf87772a638
push id104675
push usermozilla@buttercookie.de
push dateFri, 30 Mar 2018 19:09:15 +0000
reviewersesawin
bugs1278581, 976426
milestone61.0a1
Bug 1278581 - Part 4 - Ensure the progress bar doesn't get stuck after displaying the error page. r?esawin For a normal load, we get a request start, the various location change/load events and then a stop. When encountering an error (e.g. server not found), the usual event order is start, stop and then the location change/load events while the error page is loading (compare bug 976426). When displaying the "unknown protocol" error page from within the Content- DispatchChooser however, we never receive any onStateChange events from the WebProgressListener. When this happens within an existing tab, this isn't a problem - the UI never thinks that the tab is starting a page load and thanks to bug 976426 never displays the progress bar. When opening a link in a new tab, though, the UI speculatively creates the tab as STATE_LOADING and shows the progress bar. Because we never receive any state change events if the "unknown protocol" error was triggered, especially not a "Stop" event, the progress bar then never gets hidden because the UI assumes that the tab is still loading. To work around this, we make use of the error type that we were still trans- mitting during DOMContentLoaded - if an error page was detected, we reset the tab's load state in the UI and stop the progress bar. We also take this opportunity to change the handling of Content:LoadError messages. Originally, this message was intended to reset the URL bar if an attempt to load an URL resulted in an immediate error in browser.js. For un- known reasons, the rewrite from loading throbber to progress bar changed the meaning of the event to set the progress value of the progress bar to 80 %, just like DOMContentLoaded. With this patch, a Content:LoadError message will immediately stop and hide the progress bar as well. MozReview-Commit-ID: 8AXICB7mEfK
mobile/android/base/java/org/mozilla/gecko/Tab.java
mobile/android/base/java/org/mozilla/gecko/Tabs.java
--- a/mobile/android/base/java/org/mozilla/gecko/Tab.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tab.java
@@ -698,16 +698,21 @@ public class Tab {
                 if (!TextUtils.equals(oldURL, getURL()))
                     return;
 
                 ThumbnailHelper.getInstance().getAndProcessThumbnailFor(tab);
             }
         }, 500);
     }
 
+    void handleLoadError() {
+        setState(STATE_ERROR);
+        setLoadProgress(LOAD_PROGRESS_LOADED);
+    }
+
     void handleContentLoaded() {
         setLoadProgressIfLoading(LOAD_PROGRESS_LOADED);
     }
 
     protected void saveThumbnailToDB(final BrowserDB db) {
         final BitmapDrawable thumbnail = mThumbnail;
         if (thumbnail == null) {
             return;
--- a/mobile/android/base/java/org/mozilla/gecko/Tabs.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Tabs.java
@@ -632,22 +632,27 @@ public class Tabs implements BundleEvent
             } else if ((state & GeckoAppShell.WPL_STATE_STOP) != 0) {
                 Log.i(LOGTAG, "zerdatime " + SystemClock.elapsedRealtime() +
                       " - page load stop");
                 tab.handleDocumentStop(message.getBoolean("success"));
                 notifyListeners(tab, Tabs.TabEvents.STOP);
             }
 
         } else if ("Content:LoadError".equals(event)) {
-            tab.handleContentLoaded();
+            tab.handleLoadError();
             notifyListeners(tab, Tabs.TabEvents.LOAD_ERROR);
 
         } else if ("Content:DOMContentLoaded".equals(event)) {
-            tab.handleContentLoaded();
-            notifyListeners(tab, TabEvents.LOADED);
+            if (TextUtils.isEmpty(message.getString("errorType"))) {
+                tab.handleContentLoaded();
+                notifyListeners(tab, TabEvents.LOADED);
+            } else {
+                tab.handleLoadError();
+                notifyListeners(tab, TabEvents.LOAD_ERROR);
+            }
 
         } else if ("Content:PageShow".equals(event)) {
             tab.setLoadedFromCache(message.getBoolean("fromCache"));
             tab.updateUserRequested(message.getString("userRequested"));
             notifyListeners(tab, TabEvents.PAGE_SHOW);
 
         } else if ("Content:DOMTitleChanged".equals(event)) {
             tab.updateTitle(message.getString("title"));