Closed Bug 553691 Opened 14 years ago Closed 14 years ago

Stop using setTimeout to initialize the browser tools panel

Categories

(Firefox for Android Graveyard :: General, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mfinkle, Assigned: mfinkle)

Details

Attachments

(1 file)

Attached patch patchSplinter Review
We use setTimeout to delay-init the browser tools panel (prefs, add-ons, etc) at startup. We should just wait for the first web content page to load, signalling that the UI has finished loading.

This patch does that.
Attachment #433630 - Flags: review?(21)
Comment on attachment 433630 [details] [diff] [review]
patch

>diff --git a/chrome/content/browser-ui.js b/chrome/content/browser-ui.js
>--- a/chrome/content/browser-ui.js
>+++ b/chrome/content/browser-ui.js
>@@ -406,24 +406,29 @@ var BrowserUI = {
>     // listening mousedown for automatically dismiss some popups (e.g. larry)
>     window.addEventListener("mousedown", this, true);
> 
>     // listening escape to dismiss dialog on VK_ESCAPE
>     window.addEventListener("keypress", this, true);
> 
>     // Push the panel initialization out of the startup path
>     // (Using a timeout because we have no good way to delay-init [Bug 535366])

Maybe you should replace "timeout" by something else in this comment.

>-    setTimeout(function() {
>+    browsers.addEventListener("load", function() {
>+      // We only want to delay one time
>+      browsers.removeEventListener("load", arguments.callee, false);

Hey, I've never thought of doing it like that, nice trick!
Attachment #433630 - Flags: review?(21) → review+
pushed:
http://hg.mozilla.org/mobile-browser/rev/c6e8869f8618
Assignee: nobody → mark.finkle
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Looks like this change moved enough code execution out of the startup path to make a difference:
Ts before: ~12 sec N810, ~7 sec N900
Ts after: ~9.5 sec N810, ~5.5 sec N900

Txul/Twinopen also decreased
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: