Bug 1240978 - Shorten timeout for black screen in fullscreen transition. draft
authorXidorn Quan <quanxunzhen@gmail.com>
Wed, 20 Jan 2016 15:55:16 +1100
changeset 323691 8bf9e1a9bba49205bc10fae3208eae88ffd7e401
parent 323690 d60c3e271c0fe7aff6ebbd5e996069f3871e46a0
child 513265 f9002e628ef8cd4ea1444038cb81e2f6f9da0a67
push id9776
push userxquan@mozilla.com
push dateThu, 21 Jan 2016 00:03:25 +0000
bugs1240978
milestone46.0a1
Bug 1240978 - Shorten timeout for black screen in fullscreen transition.
dom/base/nsGlobalWindow.cpp
modules/libpref/init/all.js
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -5878,17 +5878,16 @@ private:
       : mTask(aTask) { }
 
   private:
     ~Observer() {}
 
     RefPtr<FullscreenTransitionTask> mTask;
   };
 
-  static const uint32_t kNextPaintTimeout = 1000; // ms
   static const char* const kPaintedTopic;
 
   RefPtr<nsGlobalWindow> mWindow;
   nsCOMPtr<nsIWidget> mWidget;
   nsCOMPtr<nsIScreen> mScreen;
   nsCOMPtr<nsITimer> mTimer;
   nsCOMPtr<nsISupports> mTransitionData;
 
@@ -5940,18 +5939,24 @@ FullscreenTransitionTask::Run()
     obs->AddObserver(observer, kPaintedTopic, false);
     // There are several edge cases where we may never get the paint
     // notification, including:
     // 1. the window/tab is closed before the next paint;
     // 2. the user has switched to another tab before we get here.
     // Completely fixing those cases seems to be tricky, and since they
     // should rarely happen, it probably isn't worth to fix. Hence we
     // simply add a timeout here to ensure we never hang forever.
+    // In addition, if the page is complicated or the machine is less
+    // powerful, layout could take a long time, in which case, staying
+    // in black screen for that long could hurt user experience even
+    // more than exposing an intermediate state.
     mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
-    mTimer->Init(observer, kNextPaintTimeout, nsITimer::TYPE_ONE_SHOT);
+    uint32_t timeout =
+      Preferences::GetUint("full-screen-api.transition.timeout", 500);
+    mTimer->Init(observer, timeout, nsITimer::TYPE_ONE_SHOT);
   } else if (stage == eAfterToggle) {
     FULLSCREEN_LOG("Task %p: transition after toggle\n", this);
     mWidget->PerformFullscreenTransition(nsIWidget::eAfterFullscreenToggle,
                                          mDuration.mFadeOut, mTransitionData,
                                          this);
   }
   return NS_OK;
 }
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -4484,16 +4484,18 @@ pref("alerts.disableSlidingEffect", fals
 
 // DOM full-screen API.
 pref("full-screen-api.enabled", false);
 pref("full-screen-api.allow-trusted-requests-only", true);
 pref("full-screen-api.pointer-lock.enabled", true);
 // transition duration of fade-to-black and fade-from-black, unit: ms
 pref("full-screen-api.transition-duration.enter", "200 200");
 pref("full-screen-api.transition-duration.leave", "200 200");
+// timeout for black screen in fullscreen transition, unit: ms
+pref("full-screen-api.transition.timeout", 500);
 // time for the warning box stays on the screen before sliding out, unit: ms
 pref("full-screen-api.warning.timeout", 3000);
 // delay for the warning box to show when pointer stays on the top, unit: ms
 pref("full-screen-api.warning.delay", 500);
 
 // DOM idle observers API
 pref("dom.idle-observers-api.enabled", true);