Taking a screenshot on the main thread delays tabs tray from opening for ~178ms
Categories
(Firefox for Android :: Performance, defect)
Tracking
()
| Performance Impact | low |
People
(Reporter: cpeterson, Unassigned)
Details
From github: https://github.com/mozilla-mobile/fenix/issues/21526.
Steps to reproduce
- Open a web page
- Click tabs tray
Expected behavior
No delay from taking screenshots.
Actual behavior
We see
runUiThreadCallbackon the main thread for 178ms (the exact time seems to vary – I've seen times as low as 120ms and higher than 178): https://share.firefox.dev/3m6UT10 In the native AndroidUI thread, we seePUiCompositorController::Msg_ScreenPixels. This was indicative of taking a screenshot. I commented out this line that takes a screenshot and the problem went away: https://share.firefox.dev/3zSFA12It's unclear how often this is called: it may be cached and only called once per each tab (though that could still be pretty bad) and this may affect prioritization.
Device information
- Android device: Moto G5
- Fenix version: main 8a15e8a6818554eb9c7d66f00e2058ecfcee6eed Sep 27
It's possible this call occurs after the tabs tray is drawn and is of little consequence to users. I confirmed this is not the case: I did this by by sleeping in an
onPreDrawlistener and manually verifying the screen contents. Here's my patch:diff --git a/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt b/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt index 509149b6e..0fa4202a5 100644 --- a/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/tabstray/TabsTrayFragment.kt @@ -13,6 +13,7 @@ import android.view.View import android.view.ViewGroup import androidx.annotation.VisibleForTesting import androidx.appcompat.app.AppCompatDialogFragment +import androidx.core.view.doOnPreDraw import androidx.core.view.isVisible import androidx.fragment.app.activityViewModels import androidx.fragment.app.setFragmentResultListener @@ -112,6 +113,13 @@ class TabsTrayFragment : AppCompatDialogFragment() { true ) + tabsTrayBinding.tabWrapper.doOnPreDraw { + it.doOnPreDraw { + Thread.sleep(3000) + requireComponents.core.engine.profiler?.addMarker("onPreDraw", "tabsTrayBinding.tabWrapper") + } + } + val args by navArgs<TabsTrayFragmentArgs>() val initialMode = if (args.enterMultiselect) { TabsTrayState.Mode.Select(emptySet())When I ran this, I saw the screen freeze on the web page with the tabs tray counter highlighted with a click event (i.e. the tabs tray did not start drawing). Here's the profile that shows the
runUiThreadCallbackscreenshot takes place before the sleep: https://share.firefox.dev/2Y45Zfi Note this is a debug build profile and the timing shouldn't be taken into account.┆Issue is synchronized with this Jira Task
Change performed by the Move to Bugzilla add-on.
Comment 1•3 years ago
|
||
The severity field is not set for this bug.
:cpeterson, could you have a look please?
For more information, please visit auto_nag documentation.
Updated•3 years ago
|
Comment 2•3 years ago
|
||
The Performance Impact Calculator has determined this bug's performance impact to be low. If you'd like to request re-triage, you can reset the Performance Impact flag to "?" or needinfo the triage sheriff.
Platforms: Android
Impact on browser: Causes noticeable jank
Websites affected: Rare
Updated•2 years ago
|
Description
•