For perf-frontend-issues#50: instrument imperfect reportFullyDrawn.
We don't capture the second RV draw yet. Unfortunately, I don't know if it's the best use of my time to capture that as well.master
parent
e5164e3670
commit
ffc441f12a
|
@ -53,6 +53,7 @@ import org.mozilla.fenix.library.bookmarks.BookmarkFragmentDirections
|
||||||
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
import org.mozilla.fenix.library.history.HistoryFragmentDirections
|
||||||
import org.mozilla.fenix.onboarding.FenixOnboarding
|
import org.mozilla.fenix.onboarding.FenixOnboarding
|
||||||
import org.mozilla.fenix.perf.HotStartPerformanceMonitor
|
import org.mozilla.fenix.perf.HotStartPerformanceMonitor
|
||||||
|
import org.mozilla.fenix.perf.Performance
|
||||||
import org.mozilla.fenix.search.SearchFragmentDirections
|
import org.mozilla.fenix.search.SearchFragmentDirections
|
||||||
import org.mozilla.fenix.settings.DefaultBrowserSettingsFragmentDirections
|
import org.mozilla.fenix.settings.DefaultBrowserSettingsFragmentDirections
|
||||||
import org.mozilla.fenix.settings.SettingsFragmentDirections
|
import org.mozilla.fenix.settings.SettingsFragmentDirections
|
||||||
|
@ -92,6 +93,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
|
||||||
|
|
||||||
setupThemeAndBrowsingMode(getModeFromIntentOrLastKnown(intent))
|
setupThemeAndBrowsingMode(getModeFromIntentOrLastKnown(intent))
|
||||||
setContentView(R.layout.activity_home)
|
setContentView(R.layout.activity_home)
|
||||||
|
Performance.instrumentColdStartupToHomescreenTime(this)
|
||||||
setupToolbarAndNavigation()
|
setupToolbarAndNavigation()
|
||||||
|
|
||||||
if (intent.getBooleanExtra(EXTRA_FINISH_ONBOARDING, false)) {
|
if (intent.getBooleanExtra(EXTRA_FINISH_ONBOARDING, false)) {
|
||||||
|
|
|
@ -4,9 +4,37 @@
|
||||||
|
|
||||||
package org.mozilla.fenix.perf
|
package org.mozilla.fenix.perf
|
||||||
|
|
||||||
|
import androidx.core.view.doOnPreDraw
|
||||||
|
import kotlinx.android.synthetic.main.activity_home.*
|
||||||
|
import org.mozilla.fenix.HomeActivity
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of objects related to app performance.
|
* A collection of objects related to app performance.
|
||||||
*/
|
*/
|
||||||
object Performance {
|
object Performance {
|
||||||
const val TAG = "FenixPerf"
|
const val TAG = "FenixPerf"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instruments cold startup time for use with our internal measuring system, FNPRMS. This may
|
||||||
|
* also appear in Google Play Vitals dashboards.
|
||||||
|
*
|
||||||
|
* This will need to be rewritten if any parts of the UI are changed to be displayed
|
||||||
|
* asynchronously.
|
||||||
|
*
|
||||||
|
* In the current implementation, we only intend to instrument cold startup to the homescreen.
|
||||||
|
* To save implementation time, we ignore the fact that the RecyclerView draws twice if the user
|
||||||
|
* has tabs, collections, etc. open: the "No tabs" placeholder and a tab list. This
|
||||||
|
* instrumentation will only capture the "No tabs" draw.
|
||||||
|
*/
|
||||||
|
fun instrumentColdStartupToHomescreenTime(activity: HomeActivity) {
|
||||||
|
// For greater accuracy, we could add an onDrawListener instead of a preDrawListener but:
|
||||||
|
// - single use onDrawListeners are not built-in and it's non-trivial to write one
|
||||||
|
// - the difference is timing is minimal (< 7ms on Pixel 2)
|
||||||
|
// - if we compare against another app using a preDrawListener, it should be comparable
|
||||||
|
//
|
||||||
|
// Unfortunately, this is tightly coupled to the root view of HomeActivity's view hierarchy
|
||||||
|
activity.rootContainer.doOnPreDraw {
|
||||||
|
activity.reportFullyDrawn()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
android:id="@+id/rootContainer"
|
||||||
tools:context=".HomeActivity">
|
tools:context=".HomeActivity">
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
|
Loading…
Reference in New Issue