diff --git a/mobile/android/base/AboutHomeContent.java.in b/mobile/android/base/AboutHomeContent.java.in index 280852ecea5..4391b9cd4ff 100644 --- a/mobile/android/base/AboutHomeContent.java.in +++ b/mobile/android/base/AboutHomeContent.java.in @@ -78,6 +78,7 @@ public class AboutHomeContent extends ScrollView private BrowserApp mActivity; private Cursor mCursor; UriLoadCallback mUriLoadCallback = null; + VoidCallback mLoadCompleteCallback = null; private LayoutInflater mInflater; private AccountManager mAccountManager; @@ -99,6 +100,10 @@ public class AboutHomeContent extends ScrollView public void callback(String uriSpec); } + public interface VoidCallback { + public void callback(); + } + public AboutHomeContent(Context context) { super(context); mContext = context; @@ -284,6 +289,12 @@ public class AboutHomeContent extends ScrollView // Free the old Cursor in the right thread now. if (oldCursor != null && !oldCursor.isClosed()) oldCursor.close(); + + // Even if AboutHome isn't necessarily entirely loaded if we + // get here, for phones this is the part the user initially sees, + // so it's the one we will care about for now. + if (mLoadCompleteCallback != null) + mLoadCompleteCallback.callback(); } }); } @@ -310,6 +321,10 @@ public class AboutHomeContent extends ScrollView mUriLoadCallback = uriLoadCallback; } + public void setLoadCompleteCallback(VoidCallback callback) { + mLoadCompleteCallback = callback; + } + public void onActivityContentChanged() { update(EnumSet.of(UpdateFlags.TOP_SITES)); } diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index 10296ab25a9..67b00ca3af0 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -639,12 +639,16 @@ abstract public class BrowserApp extends GeckoApp loadUrl(url, AwesomeBar.Target.CURRENT_TAB); } }); + mAboutHomeContent.setLoadCompleteCallback(new AboutHomeContent.VoidCallback() { + public void callback() { + mAboutHomeStartupTimer.stop(); + } + }); mAboutHomeContent.setOnInterceptTouchListener(new ContentTouchListener()); } else { mAboutHomeContent.update(EnumSet.of(AboutHomeContent.UpdateFlags.TOP_SITES, AboutHomeContent.UpdateFlags.REMOTE_TABS)); } - mAboutHomeContent.setVisibility(View.VISIBLE); } else { findViewById(R.id.abouthome_content).setVisibility(View.GONE); diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index 8900d58b3e0..04e7839d53e 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -176,6 +176,9 @@ abstract public class GeckoApp protected int mRestoreMode = GeckoAppShell.RESTORE_NONE; protected boolean mInitialized = false; + protected Telemetry.Timer mAboutHomeStartupTimer; + private Telemetry.Timer mJavaUiStartupTimer; + private Telemetry.Timer mGeckoReadyStartupTimer; public enum LaunchState {Launching, WaitForDebugger, Launched, GeckoRunning, GeckoExiting}; @@ -970,6 +973,7 @@ abstract public class GeckoApp final int tabId = message.getInt("tabID"); handlePageShow(tabId); } else if (event.equals("Gecko:Ready")) { + mGeckoReadyStartupTimer.stop(); sIsGeckoReady = true; setLaunchState(GeckoApp.LaunchState.GeckoRunning); GeckoAppShell.sendPendingEventsToGecko(); @@ -1439,9 +1443,15 @@ abstract public class GeckoApp @Override public void onCreate(Bundle savedInstanceState) { - ((GeckoApplication)getApplication()).initialize(); GeckoAppShell.registerGlobalExceptionHandler(); + // The clock starts...now. Better hurry! + mJavaUiStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_JAVAUI"); + mAboutHomeStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_ABOUTHOME"); + mGeckoReadyStartupTimer = new Telemetry.Timer("FENNEC_STARTUP_TIME_GECKOREADY"); + + ((GeckoApplication)getApplication()).initialize(); + mAppContext = this; Tabs.getInstance().attachToActivity(this); @@ -1690,6 +1700,9 @@ abstract public class GeckoApp final GeckoApp self = this; + // End of the startup of our Java App + mJavaUiStartupTimer.stop(); + GeckoAppShell.getHandler().postDelayed(new Runnable() { public void run() { Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - pre checkLaunchState"); diff --git a/mobile/android/base/Telemetry.java b/mobile/android/base/Telemetry.java index 4fbb7dc804c..9245fd8301f 100644 --- a/mobile/android/base/Telemetry.java +++ b/mobile/android/base/Telemetry.java @@ -37,13 +37,22 @@ public class Telemetry { public static class Timer { private long mStartTime; private String mName; + private boolean mHasFinished; public Timer(String name) { mName = name; mStartTime = SystemClock.uptimeMillis(); + mHasFinished = false; } public void stop() { + // Only the first stop counts. + if (mHasFinished) { + return; + } else { + mHasFinished = true; + } + long elapsed = SystemClock.uptimeMillis() - mStartTime; if (elapsed < Integer.MAX_VALUE) { HistogramAdd(mName, (int)(elapsed)); diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 3d6402312cc..86cfc7c374b 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -26,14 +26,6 @@ "n_buckets": 50, "description": "time spent updating accessibility (ms)" }, - "FENNEC_AWESOMEBAR_ALLPAGES_EMPTY_TIME": { - "kind": "exponential", - "low": 10, - "high": "20000", - "n_buckets": 20, - "description": "Fennec: Time for the Awesomebar Top Sites query to return with no filter set (ms)", - "cpp_guard": "ANDROID" - }, "CYCLE_COLLECTOR": { "kind": "exponential", "high": "10000", @@ -2243,6 +2235,38 @@ "description": "Number of history entries in the original XUL places database", "cpp_guard": "ANDROID" }, + "FENNEC_AWESOMEBAR_ALLPAGES_EMPTY_TIME": { + "kind": "exponential", + "low": 10, + "high": "20000", + "n_buckets": 20, + "description": "Fennec: Time for the Awesomebar Top Sites query to return with no filter set (ms)", + "cpp_guard": "ANDROID" + }, + "FENNEC_STARTUP_TIME_JAVAUI": { + "kind": "exponential", + "low": 100, + "high": "5000", + "n_buckets": 20, + "description": "Time for the Java UI to load (ms)", + "cpp_guard": "ANDROID" + }, + "FENNEC_STARTUP_TIME_ABOUTHOME": { + "kind": "exponential", + "low": 100, + "high": "10000", + "n_buckets": 20, + "description": "Time for the about:home page to be displayed (ms)", + "cpp_guard": "ANDROID" + }, + "FENNEC_STARTUP_TIME_GECKOREADY": { + "kind": "exponential", + "low": 500, + "high": "20000", + "n_buckets": 20, + "description": "Time for the Gecko:Ready message to arrive (ms)", + "cpp_guard": "ANDROID" + }, "OUT_OF_MEMORY_KILLED": { "kind": "flag", "description": "Killed due to an OOM condition",