For #20596 remove perf.startup probes

upstream-sync
Rohan Maity 3 years ago committed by mergify[bot]
parent 70a90a0291
commit c45703db07

@ -4697,165 +4697,6 @@ perf.startup:
- perf-android-fe@mozilla.com - perf-android-fe@mozilla.com
- mcomella@mozilla.com - mcomella@mozilla.com
expires: "2022-02-01" expires: "2022-02-01"
app_on_create_to_glean_init:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
A subsection of the duration of `FenixApplication.onCreate` and thus the
`application_on_create` probe from the start of the method through when
`initializeGlean` is called. Note: `initializeGlean` is a no-op for Beta
and Release builds which instead initialize it during
`MigratingFenixApplication`, which we don't currently measure.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18525#issue-594961170
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
app_on_create_to_megazord_init:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
A subsection of the duration of `FenixApplication.onCreate` and thus the
`application_on_create` probe from after the `app_on_create_to_glean_init`
probe until we block for the megazord to complete set up.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18525#issue-594961170
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
app_on_create_to_setup_in_main:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
A subsection of the duration of `FenixApplication.onCreate` and thus the
`application_on_create` probe from after the
`app_on_create_to_megazord_init` probe until the end of
`setupInMainProcessOnly`, which is expected to be the end of the
`onCreate` call (unless the implementation later changes).
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18525#issue-594961170
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
home_activity_on_create:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
The duration of `HomeActivity.onCreate`.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/17969
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/17973#issue-572183889
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
home_activity_on_start:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
The duration of `HomeActivity.onStart`. This may encapsulate
`HomeFragment` or `BrowserFragment` creation, depending on the code path,
so we expect this to take varying amounts of time. As such, this probe may
not be easy to interpret directly but we believe collecting it may give us
more information about different patterns we might see in performance
data.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18558#issue-596791848
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
home_fragment_on_create_view:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
The duration of `HomeFragment.onCreateView`.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18558#issue-596791848
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
home_fragment_on_view_created:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
The duration of `HomeFragment.onViewCreated`.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18558#issue-596791848
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
base_bfragment_on_create_view:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
The duration of `BaseBrowserFragment.onCreateView`.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18558#issue-596791848
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
base_bfragment_on_view_created:
disabled: true
type: timing_distribution
time_unit: millisecond
description: |
The duration of `BaseBrowserFragment.onViewCreated`.
bugs:
- https://github.com/mozilla-mobile/fenix/issues/18426
data_reviews:
- https://github.com/mozilla-mobile/fenix/pull/18558#issue-596791848
data_sensitivity:
- technical
notification_emails:
- perf-android-fe@mozilla.com
- mcomella@mozilla.com
expires: "2021-08-11"
startup_type: startup_type:
type: labeled_counter type: labeled_counter
description: | description: |

@ -51,7 +51,6 @@ import org.mozilla.fenix.GleanMetrics.PerfStartup
import org.mozilla.fenix.components.Components import org.mozilla.fenix.components.Components
import org.mozilla.fenix.components.metrics.MetricServiceType import org.mozilla.fenix.components.metrics.MetricServiceType
import org.mozilla.fenix.components.metrics.SecurePrefsTelemetry import org.mozilla.fenix.components.metrics.SecurePrefsTelemetry
import org.mozilla.fenix.ext.measureNoInline
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.perf.ProfilerMarkerFactProcessor import org.mozilla.fenix.perf.ProfilerMarkerFactProcessor
import org.mozilla.fenix.perf.StartupTimeline import org.mozilla.fenix.perf.StartupTimeline
@ -98,7 +97,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
override fun onCreate() { override fun onCreate() {
// We use start/stop instead of measure so we don't measure outside the main process. // We use start/stop instead of measure so we don't measure outside the main process.
val completeMethodDurationTimerId = PerfStartup.applicationOnCreate.start() // DO NOT MOVE ANYTHING ABOVE HERE. val completeMethodDurationTimerId = PerfStartup.applicationOnCreate.start() // DO NOT MOVE ANYTHING ABOVE HERE.
val subsectionThroughGleanTimerId = PerfStartup.appOnCreateToGleanInit.start()
super.onCreate() super.onCreate()
@ -120,8 +118,6 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
initializeGlean() initializeGlean()
} }
PerfStartup.appOnCreateToGleanInit.stopAndAccumulate(subsectionThroughGleanTimerId)
setupInMainProcessOnly() setupInMainProcessOnly()
// DO NOT MOVE ANYTHING BELOW THIS stop CALL. // DO NOT MOVE ANYTHING BELOW THIS stop CALL.
@ -163,54 +159,50 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
@CallSuper @CallSuper
open fun setupInMainProcessOnly() { open fun setupInMainProcessOnly() {
PerfStartup.appOnCreateToMegazordInit.measureNoInline { ProfilerMarkerFactProcessor.create { components.core.engine.profiler }.register()
ProfilerMarkerFactProcessor.create { components.core.engine.profiler }.register()
run { run {
// Attention: Do not invoke any code from a-s in this scope. // Attention: Do not invoke any code from a-s in this scope.
val megazordSetup = setupMegazord() val megazordSetup = setupMegazord()
setDayNightTheme() setDayNightTheme()
components.strictMode.enableStrictMode(true) components.strictMode.enableStrictMode(true)
warmBrowsersCache() warmBrowsersCache()
// Make sure the engine is initialized and ready to use. // Make sure the engine is initialized and ready to use.
components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) { components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
components.core.engine.warmUp() components.core.engine.warmUp()
} }
initializeWebExtensionSupport() initializeWebExtensionSupport()
restoreBrowserState() restoreBrowserState()
restoreDownloads() restoreDownloads()
// Just to make sure it is impossible for any application-services pieces // Just to make sure it is impossible for any application-services pieces
// to invoke parts of itself that require complete megazord initialization // to invoke parts of itself that require complete megazord initialization
// before that process completes, we wait here, if necessary. // before that process completes, we wait here, if necessary.
if (!megazordSetup.isCompleted) { if (!megazordSetup.isCompleted) {
runBlockingIncrement { megazordSetup.await() } runBlockingIncrement { megazordSetup.await() }
}
} }
} }
PerfStartup.appOnCreateToSetupInMain.measureNoInline { setupLeakCanary()
setupLeakCanary() startMetricsIfEnabled()
startMetricsIfEnabled() setupPush()
setupPush()
visibilityLifecycleCallback = VisibilityLifecycleCallback(getSystemService()) visibilityLifecycleCallback = VisibilityLifecycleCallback(getSystemService())
registerActivityLifecycleCallbacks(visibilityLifecycleCallback) registerActivityLifecycleCallbacks(visibilityLifecycleCallback)
// Storage maintenance disabled, for now, as it was interfering with background migrations. // Storage maintenance disabled, for now, as it was interfering with background migrations.
// See https://github.com/mozilla-mobile/fenix/issues/7227 for context. // See https://github.com/mozilla-mobile/fenix/issues/7227 for context.
// if ((System.currentTimeMillis() - settings().lastPlacesStorageMaintenance) > ONE_DAY_MILLIS) { // if ((System.currentTimeMillis() - settings().lastPlacesStorageMaintenance) > ONE_DAY_MILLIS) {
// runStorageMaintenance() // runStorageMaintenance()
// } // }
components.appStartReasonProvider.registerInAppOnCreate(this) components.appStartReasonProvider.registerInAppOnCreate(this)
components.startupActivityLog.registerInAppOnCreate(this) components.startupActivityLog.registerInAppOnCreate(this)
initVisualCompletenessQueueAndQueueTasks() initVisualCompletenessQueueAndQueueTasks()
ProcessLifecycleOwner.get().lifecycle.addObserver(TelemetryLifecycleObserver(components.core.store)) ProcessLifecycleOwner.get().lifecycle.addObserver(TelemetryLifecycleObserver(components.core.store))
}
} }
@OptIn(DelicateCoroutinesApi::class) // GlobalScope usage @OptIn(DelicateCoroutinesApi::class) // GlobalScope usage

@ -67,7 +67,6 @@ import mozilla.components.support.utils.SafeIntent
import mozilla.components.support.utils.toSafeIntent import mozilla.components.support.utils.toSafeIntent
import mozilla.components.support.webextensions.WebExtensionPopupFeature import mozilla.components.support.webextensions.WebExtensionPopupFeature
import org.mozilla.fenix.GleanMetrics.Metrics import org.mozilla.fenix.GleanMetrics.Metrics
import org.mozilla.fenix.GleanMetrics.PerfStartup
import org.mozilla.fenix.addons.AddonDetailsFragmentDirections import org.mozilla.fenix.addons.AddonDetailsFragmentDirections
import org.mozilla.fenix.addons.AddonPermissionsDetailsFragmentDirections import org.mozilla.fenix.addons.AddonPermissionsDetailsFragmentDirections
import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.browser.browsingmode.BrowsingMode
@ -79,7 +78,6 @@ import org.mozilla.fenix.exceptions.trackingprotection.TrackingProtectionExcepti
import org.mozilla.fenix.ext.alreadyOnDestination import org.mozilla.fenix.ext.alreadyOnDestination
import org.mozilla.fenix.ext.breadcrumb import org.mozilla.fenix.ext.breadcrumb
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.measureNoInline
import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.setNavigationIcon import org.mozilla.fenix.ext.setNavigationIcon
@ -177,7 +175,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
private val startupPathProvider = StartupPathProvider() private val startupPathProvider = StartupPathProvider()
private lateinit var startupTypeTelemetry: StartupTypeTelemetry private lateinit var startupTypeTelemetry: StartupTypeTelemetry
final override fun onCreate(savedInstanceState: Bundle?): Unit = PerfStartup.homeActivityOnCreate.measureNoInline { final override fun onCreate(savedInstanceState: Bundle?) {
// DO NOT MOVE ANYTHING ABOVE THIS addMarker CALL. // DO NOT MOVE ANYTHING ABOVE THIS addMarker CALL.
components.core.engine.profiler?.addMarker("Activity.onCreate", "HomeActivity") components.core.engine.profiler?.addMarker("Activity.onCreate", "HomeActivity")
@ -311,7 +309,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
isFenixTheDefaultBrowser() isFenixTheDefaultBrowser()
} }
override fun onStart() = PerfStartup.homeActivityOnStart.measureNoInline { override fun onStart() {
super.onStart() super.onStart()
// Diagnostic breadcrumb for "Display already aquired" crash: // Diagnostic breadcrumb for "Display already aquired" crash:

@ -133,10 +133,8 @@ import mozilla.components.feature.webauthn.WebAuthnFeature
import mozilla.components.support.base.feature.ActivityResultHandler import mozilla.components.support.base.feature.ActivityResultHandler
import mozilla.components.support.ktx.android.view.enterToImmersiveMode import mozilla.components.support.ktx.android.view.enterToImmersiveMode
import mozilla.components.support.ktx.kotlin.getOrigin import mozilla.components.support.ktx.kotlin.getOrigin
import org.mozilla.fenix.GleanMetrics.PerfStartup
import org.mozilla.fenix.components.toolbar.interactor.BrowserToolbarInteractor import org.mozilla.fenix.components.toolbar.interactor.BrowserToolbarInteractor
import org.mozilla.fenix.components.toolbar.interactor.DefaultBrowserToolbarInteractor import org.mozilla.fenix.components.toolbar.interactor.DefaultBrowserToolbarInteractor
import org.mozilla.fenix.ext.measureNoInline
import org.mozilla.fenix.ext.secure import org.mozilla.fenix.ext.secure
import org.mozilla.fenix.settings.biometric.BiometricPromptFeature import org.mozilla.fenix.settings.biometric.BiometricPromptFeature
import mozilla.components.feature.session.behavior.ToolbarPosition as MozacToolbarPosition import mozilla.components.feature.session.behavior.ToolbarPosition as MozacToolbarPosition
@ -212,7 +210,7 @@ abstract class BaseBrowserFragment :
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View = PerfStartup.baseBfragmentOnCreateView.measureNoInline { ): View {
customTabSessionId = requireArguments().getString(EXTRA_SESSION_ID) customTabSessionId = requireArguments().getString(EXTRA_SESSION_ID)
// Diagnostic breadcrumb for "Display already aquired" crash: // Diagnostic breadcrumb for "Display already aquired" crash:
@ -235,30 +233,29 @@ abstract class BaseBrowserFragment :
) )
} }
view return view
} }
final override fun onViewCreated(view: View, savedInstanceState: Bundle?) = final override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
PerfStartup.baseBfragmentOnViewCreated.measureNoInline { // weird indentation to avoid breaking blame. // weird indentation to avoid breaking blame.
initializeUI(view) initializeUI(view)
if (customTabSessionId == null) { if (customTabSessionId == null) {
// We currently only need this observer to navigate to home // We currently only need this observer to navigate to home
// in case all tabs have been removed on startup. No need to // in case all tabs have been removed on startup. No need to
// this if we have a known session to display. // this if we have a known session to display.
observeRestoreComplete(requireComponents.core.store, findNavController()) observeRestoreComplete(requireComponents.core.store, findNavController())
} }
observeTabSelection(requireComponents.core.store)
if (!onboarding.userHasBeenOnboarded()) { observeTabSelection(requireComponents.core.store)
observeTabSource(requireComponents.core.store)
}
requireContext().accessibilityManager.addAccessibilityStateChangeListener(this) if (!onboarding.userHasBeenOnboarded()) {
Unit observeTabSource(requireComponents.core.store)
} }
requireContext().accessibilityManager.addAccessibilityStateChangeListener(this)
}
private fun initializeUI(view: View) { private fun initializeUI(view: View) {
val tab = getCurrentTab() val tab = getCurrentTab()
browserInitialized = if (tab != null) { browserInitialized = if (tab != null) {

@ -1,31 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.ext
import mozilla.telemetry.glean.private.TimingDistributionMetricType
/**
* A reimplementation of [TimingDistributionMetricType.measure] that address unintuitive
* issues around non-local returns: see https://bugzilla.mozilla.org/show_bug.cgi?id=1699505.
* This should be removed once that bug is resolved. That method's kdoc is as follows:
*
* Convenience method to simplify measuring a function or block of code.
*
* If the measured function throws, the measurement is canceled and the exception rethrown.
*/
@Suppress("TooGenericExceptionCaught")
fun <U> TimingDistributionMetricType.measureNoInline(funcToMeasure: () -> U): U {
val timerId = start()
val returnValue = try {
funcToMeasure()
} catch (e: Exception) {
cancel(timerId)
throw e
}
stopAndAccumulate(timerId)
return returnValue
}

@ -78,7 +78,6 @@ import mozilla.components.ui.tabcounter.TabCounterMenu
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.Config import org.mozilla.fenix.Config
import org.mozilla.fenix.FeatureFlags import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.GleanMetrics.PerfStartup
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R import org.mozilla.fenix.R
import org.mozilla.fenix.browser.BrowserAnimator.Companion.getToolbarNavOptions import org.mozilla.fenix.browser.BrowserAnimator.Companion.getToolbarNavOptions
@ -97,7 +96,6 @@ import org.mozilla.fenix.components.toolbar.FenixTabCounterMenu
import org.mozilla.fenix.components.toolbar.ToolbarPosition import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.hideToolbar import org.mozilla.fenix.ext.hideToolbar
import org.mozilla.fenix.ext.measureNoInline
import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.metrics
import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.ext.requireComponents
@ -200,7 +198,7 @@ class HomeFragment : Fragment() {
inflater: LayoutInflater, inflater: LayoutInflater,
container: ViewGroup?, container: ViewGroup?,
savedInstanceState: Bundle? savedInstanceState: Bundle?
): View? = PerfStartup.homeFragmentOnCreateView.measureNoInline { ): View? {
val view = inflater.inflate(R.layout.fragment_home, container, false) val view = inflater.inflate(R.layout.fragment_home, container, false)
val activity = activity as HomeActivity val activity = activity as HomeActivity
val components = requireComponents val components = requireComponents
@ -339,7 +337,7 @@ class HomeFragment : Fragment() {
appBarLayout = view.homeAppBar appBarLayout = view.homeAppBar
activity.themeManager.applyStatusBarTheme(activity) activity.themeManager.applyStatusBarTheme(activity)
view return view
} }
override fun onConfigurationChanged(newConfig: Configuration) { override fun onConfigurationChanged(newConfig: Configuration) {
@ -421,87 +419,86 @@ class HomeFragment : Fragment() {
} }
@Suppress("LongMethod", "ComplexMethod") @Suppress("LongMethod", "ComplexMethod")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) = override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
PerfStartup.homeFragmentOnViewCreated.measureNoInline { super.onViewCreated(view, savedInstanceState)
super.onViewCreated(view, savedInstanceState) context?.metrics?.track(Event.HomeScreenDisplayed)
context?.metrics?.track(Event.HomeScreenDisplayed)
observeSearchEngineChanges()
observeSearchEngineChanges() createHomeMenu(requireContext(), WeakReference(view.menuButton))
createHomeMenu(requireContext(), WeakReference(view.menuButton)) createTabCounterMenu(view)
createTabCounterMenu(view)
view.menuButton.setColorFilter(
view.menuButton.setColorFilter( ContextCompat.getColor(
ContextCompat.getColor( requireContext(),
requireContext(), ThemeManager.resolveAttribute(R.attr.primaryText, requireContext())
ThemeManager.resolveAttribute(R.attr.primaryText, requireContext())
)
) )
)
view.toolbar.compoundDrawablePadding = view.toolbar.compoundDrawablePadding =
view.resources.getDimensionPixelSize(R.dimen.search_bar_search_engine_icon_padding) view.resources.getDimensionPixelSize(R.dimen.search_bar_search_engine_icon_padding)
view.toolbar_wrapper.setOnClickListener { view.toolbar_wrapper.setOnClickListener {
navigateToSearch() navigateToSearch()
requireComponents.analytics.metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.HOME)) requireComponents.analytics.metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.HOME))
} }
view.toolbar_wrapper.setOnLongClickListener { view.toolbar_wrapper.setOnLongClickListener {
ToolbarPopupWindow.show( ToolbarPopupWindow.show(
WeakReference(it), WeakReference(it),
handlePasteAndGo = sessionControlInteractor::onPasteAndGo, handlePasteAndGo = sessionControlInteractor::onPasteAndGo,
handlePaste = sessionControlInteractor::onPaste, handlePaste = sessionControlInteractor::onPaste,
copyVisible = false copyVisible = false
) )
true true
} }
view.tab_button.setOnClickListener { view.tab_button.setOnClickListener {
if (FeatureFlags.showStartOnHomeSettings) { if (FeatureFlags.showStartOnHomeSettings) {
requireComponents.analytics.metrics.track(Event.StartOnHomeOpenTabsTray) requireComponents.analytics.metrics.track(Event.StartOnHomeOpenTabsTray)
}
openTabsTray()
} }
openTabsTray()
}
PrivateBrowsingButtonView( PrivateBrowsingButtonView(
privateBrowsingButton, privateBrowsingButton,
browsingModeManager browsingModeManager
) { newMode -> ) { newMode ->
if (newMode == BrowsingMode.Private) { if (newMode == BrowsingMode.Private) {
requireContext().settings().incrementNumTimesPrivateModeOpened() requireContext().settings().incrementNumTimesPrivateModeOpened()
}
if (onboarding.userHasBeenOnboarded()) {
homeFragmentStore.dispatch(
HomeFragmentAction.ModeChange(Mode.fromBrowsingMode(newMode))
)
}
} }
consumeFrom(requireComponents.core.store) { if (onboarding.userHasBeenOnboarded()) {
updateTabCounter(it) homeFragmentStore.dispatch(
HomeFragmentAction.ModeChange(Mode.fromBrowsingMode(newMode))
)
} }
}
homeViewModel.sessionToDelete?.also { consumeFrom(requireComponents.core.store) {
if (it == ALL_NORMAL_TABS || it == ALL_PRIVATE_TABS) { updateTabCounter(it)
removeAllTabsAndShowSnackbar(it) }
} else {
removeTabAndShowSnackbar(it) homeViewModel.sessionToDelete?.also {
} if (it == ALL_NORMAL_TABS || it == ALL_PRIVATE_TABS) {
removeAllTabsAndShowSnackbar(it)
} else {
removeTabAndShowSnackbar(it)
} }
}
homeViewModel.sessionToDelete = null homeViewModel.sessionToDelete = null
updateTabCounter(requireComponents.core.store.state) updateTabCounter(requireComponents.core.store.state)
if (bundleArgs.getBoolean(FOCUS_ON_ADDRESS_BAR)) { if (bundleArgs.getBoolean(FOCUS_ON_ADDRESS_BAR)) {
navigateToSearch() navigateToSearch()
} else if (bundleArgs.getLong(FOCUS_ON_COLLECTION, -1) >= 0) { } else if (bundleArgs.getLong(FOCUS_ON_COLLECTION, -1) >= 0) {
// No need to scroll to async'd loaded TopSites if we want to scroll to collections. // No need to scroll to async'd loaded TopSites if we want to scroll to collections.
homeViewModel.shouldScrollToTopSites = false homeViewModel.shouldScrollToTopSites = false
/* Triggered when the user has added a tab to a collection and has tapped /* Triggered when the user has added a tab to a collection and has tapped
* the View action on the [TabsTrayDialogFragment] snackbar.*/ * the View action on the [TabsTrayDialogFragment] snackbar.*/
scrollAndAnimateCollection(bundleArgs.getLong(FOCUS_ON_COLLECTION, -1)) scrollAndAnimateCollection(bundleArgs.getLong(FOCUS_ON_COLLECTION, -1))
}
} }
}
private fun observeSearchEngineChanges() { private fun observeSearchEngineChanges() {
consumeFlow(store) { flow -> consumeFlow(store) { flow ->

@ -20,11 +20,9 @@ import org.junit.Assert.assertNotEquals
import org.junit.Assert.assertNull import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue import org.junit.Assert.assertTrue
import org.junit.Before import org.junit.Before
import org.junit.Ignore
import org.junit.Rule import org.junit.Rule
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.mozilla.fenix.GleanMetrics.PerfStartup
import org.mozilla.fenix.HomeActivity.Companion.PRIVATE_BROWSING_MODE import org.mozilla.fenix.HomeActivity.Companion.PRIVATE_BROWSING_MODE
import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager
@ -33,7 +31,6 @@ import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.utils.Settings import org.mozilla.fenix.utils.Settings
import org.robolectric.Robolectric
@RunWith(FenixRobolectricTestRunner::class) @RunWith(FenixRobolectricTestRunner::class)
class HomeActivityTest { class HomeActivityTest {
@ -166,21 +163,4 @@ class HomeActivityTest {
assertFalse(activity.shouldStartOnHome(startingIntent)) assertFalse(activity.shouldStartOnHome(startingIntent))
} }
@Ignore("failed after library upgrade, see: https://github.com/mozilla-mobile/fenix/issues/19921")
@Test
fun `WHEN onCreate is called THEN the duration is measured`() {
assertFalse(PerfStartup.homeActivityOnCreate.testHasValue()) // sanity check.
// For some reason, the androidx replacement for this method, ActivityScenario, fails so we
// use the old Robolectric version. Perhaps it's because it forces the Activity to the
// RESUMED state (unlike Robolectric where we can get to CREATED) so not enough code is
// mocked for that to work.
//
// There are various exceptions thrown on background threads when this test runs but it
// doesn't seem to impact correctness so we ignore them.
Robolectric.buildActivity(HomeActivity::class.java)
.create()
assertTrue(PerfStartup.homeActivityOnCreate.testHasValue())
}
} }

Loading…
Cancel
Save