[fenix] For https://github.com/mozilla-mobile/fenix/issues/21921: add durations for some HomeFragment lifecycle markers.

pull/600/head
Michael Comella 3 years ago committed by mergify[bot]
parent 9a784f8484
commit 9926c27e43

@ -120,6 +120,7 @@ import org.mozilla.fenix.home.sessioncontrol.SessionControlView
import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionViewHolder
import org.mozilla.fenix.home.topsites.DefaultTopSitesView
import org.mozilla.fenix.onboarding.FenixOnboarding
import org.mozilla.fenix.perf.MarkersFragmentLifecycleCallbacks
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.settings.SupportUtils.SumoTopic.HELP
import org.mozilla.fenix.settings.deletebrowsingdata.deleteAndQuit
@ -186,6 +187,9 @@ class HomeFragment : Fragment() {
internal var getMenuButton: () -> MenuButton? = { binding.menuButton }
override fun onCreate(savedInstanceState: Bundle?) {
// DO NOT ADD ANYTHING ABOVE THIS getProfilerTime CALL!
val profilerStartTime = requireComponents.core.engine.profiler?.getProfilerTime()
super.onCreate(savedInstanceState)
bundleArgs = args.toBundle()
@ -201,6 +205,11 @@ class HomeFragment : Fragment() {
) {
showPrivacyPopWindow(requireContext(), requireActivity())
}
// DO NOT MOVE ANYTHING BELOW THIS addMarker CALL!
requireComponents.core.engine.profiler?.addMarker(
MarkersFragmentLifecycleCallbacks.MARKER_NAME, profilerStartTime, "HomeFragment.onCreate",
)
}
@Suppress("LongMethod")
@ -209,6 +218,9 @@ class HomeFragment : Fragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
// DO NOT ADD ANYTHING ABOVE THIS getProfilerTime CALL!
val profilerStartTime = requireComponents.core.engine.profiler?.getProfilerTime()
_binding = FragmentHomeBinding.inflate(inflater, container, false)
val activity = activity as HomeActivity
val components = requireComponents
@ -378,6 +390,11 @@ class HomeFragment : Fragment() {
activity.themeManager.applyStatusBarTheme(activity)
requireContext().components.analytics.experiments.recordExposureEvent(FeatureId.HOME_PAGE)
// DO NOT MOVE ANYTHING BELOW THIS addMarker CALL!
requireComponents.core.engine.profiler?.addMarker(
MarkersFragmentLifecycleCallbacks.MARKER_NAME, profilerStartTime, "HomeFragment.onCreateView",
)
return binding.root
}
@ -461,6 +478,9 @@ class HomeFragment : Fragment() {
@Suppress("LongMethod", "ComplexMethod")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
// DO NOT ADD ANYTHING ABOVE THIS getProfilerTime CALL!
val profilerStartTime = requireComponents.core.engine.profiler?.getProfilerTime()
super.onViewCreated(view, savedInstanceState)
context?.metrics?.track(Event.HomeScreenDisplayed)
@ -531,6 +551,11 @@ class HomeFragment : Fragment() {
* the View action on the [TabsTrayDialogFragment] snackbar.*/
scrollAndAnimateCollection(bundleArgs.getLong(FOCUS_ON_COLLECTION, -1))
}
// DO NOT MOVE ANYTHING BELOW THIS addMarker CALL!
requireComponents.core.engine.profiler?.addMarker(
MarkersFragmentLifecycleCallbacks.MARKER_NAME, profilerStartTime, "HomeFragment.onViewCreated",
)
}
private fun observeSearchEngineChanges() {

@ -9,7 +9,9 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import kotlinx.coroutines.ExperimentalCoroutinesApi
import mozilla.components.concept.engine.Engine
import org.mozilla.fenix.home.HomeFragment
/**
* Adds a profiler marker for each fragment lifecycle callbacks. The callbacks are called by the
@ -17,6 +19,7 @@ import mozilla.components.concept.engine.Engine
* our implementation (e.g. [org.mozilla.fenix.home.HomeFragment.onCreate]) rather than at the
* beginning or end of that method.
*/
@ExperimentalCoroutinesApi // reference to HomeFragment causes cascade.
@Suppress("TooManyFunctions") // it's the interface so we don't have a choice
class MarkersFragmentLifecycleCallbacks(
private val engine: Engine
@ -67,7 +70,10 @@ class MarkersFragmentLifecycleCallbacks(
}
override fun onFragmentCreated(fm: FragmentManager, f: Fragment, savedInstanceState: Bundle?) {
if (shouldSkip()) {
if (shouldSkip() ||
// These methods are manually instrumented with duration.
f is HomeFragment
) {
return
}
@ -75,7 +81,10 @@ class MarkersFragmentLifecycleCallbacks(
}
override fun onFragmentViewCreated(fm: FragmentManager, f: Fragment, v: View, savedInstanceState: Bundle?) {
if (shouldSkip()) {
if (shouldSkip() ||
// These methods are manually instrumented with duration.
f is HomeFragment
) {
return
}

Loading…
Cancel
Save