Closed Bug 1906726 Opened 1 year ago Closed 1 year ago

Fenix pageload progress bar can take multiple times longer to complete than Chrome (e.g. 50 seconds vs 10 seconds)

Categories

(Core :: Performance: General, defect, P1)

defect

Tracking

()

RESOLVED FIXED
136 Branch
Performance Impact none
Tracking Status
firefox136 --- fixed

People

(Reporter: acreskey, Assigned: kaya)

References

(Blocks 4 open bugs)

Details

(Whiteboard: [avocado sprint])

User Story

Added to high friction list because this appears to a cause of a recurring theme from from Google Play Store reviews: slow page loading, pages not loading 

e.g.
```
Felt Slowness
    Description: Users are reporting slow page loading, pages not loading, slow browsing speed, slow app responsiveness, and slow media.
```

Attachments

(10 files)

​​The pageload progress indicator in Fenix can drag on well beyond the point at which the content is loaded and rendered.
Compared to Chrome this can lead to a lower quality user experience as it appears that the page is still loading.

Steps to Reproduce:

To emphasize the impact, ensure you are on a slower network.
For example, the videos attached were made on a network with 3mbps throughput and ~300ms rtt latency.

Load a large top site (e.g. nytimes.com wsj.com etc)
Observe how long it takes for the page load progress bar to complete

Expected Results:

Pageload progress bar completes roughly when page is loaded

Actual Results:

In Fenix the indicator can stall and take up to 50seconds (as in the video)

In Chrome, same network, same site, I am seeing the progress bar complete in about 10 seconds.

System configuration:

Samsung A54

Fenix loading nytimes on slower network, part 1 of 2 due to file size restrictions.

Fenix loading nytimes on slower network, part 2 of 2 due to file size restrictions.

Attached video Chrome_nytimes.mov
Blocks: necko-perf

The pageload progress bar was a bit faster in this profile, but still about 27 seconds long

https://share.firefox.dev/3zwLSJ4

And a 36 second document load with nsHttp logs as markers
https://share.firefox.dev/4cRmNqK

A Chrome performance trace of the same site, same network is here

And another profiler in the chrome://tracing format is here

Not clear yet, but perhaps Chrome is completing the progress bar on DomContentLoaded?

As Markus pointed out, while the progress bar completed in the Chrome load (comment 6), but the load event had not yet fired.

In this Chrome trace we can see DCL firing just before 12 seconds but the load event not until much later, about 23 seconds.

The progress bar completes much closer to DCL, roughly at around 10-12 seconds.

In bug 1889771 we just increased the maximum parallel http connections on Android from 40 to 128.
We have data from CI and local tests that show (as expected) that one impact of the change is load time being decreased, sometimes by up to 40%.

We should re-test this with the 128 socket change landed.

Flags: needinfo?(acreskey)

(In reply to Andrew Creskey [:acreskey] from comment #9)

In bug 1889771 we just increased the maximum parallel http connections on Android from 40 to 128.
We have data from CI and local tests that show (as expected) that one impact of the change is load time being decreased, sometimes by up to 40%.

We should re-test this with the 128 socket change landed.

From local tests on nytimes.com, cnn.com, the slow progress bar is not improved with bug 1889771.

Flags: needinfo?(acreskey)

https://cnn.com in particular makes a very good test case.

On the same network, 3mbps throughput and ~300ms rtt latency:

Chrome has the loading progress bar complete in under 10 seconds.
In Fenix, it's about 1 minute or longer.

In this profile, resources continue to trickle in for about 90 seconds, at which point the loading indicator finally completes:
https://share.firefox.dev/3Lv96C0

Assignee: nobody → tchoh
Status: NEW → ASSIGNED
Blocks: 1894804
User Story: (updated)
See Also: → 1909562
Whiteboard: [avocado sprint]
Blocks: 1913418
No longer blocks: 1913418
Severity: -- → S4
Performance Impact: --- → none

In bug 1915490 and bug 1915186 we've standardized how we categorize and prioritize trackers between nightly/beta/release.

So retesting this one, but still seeing Chrome complete the progress bar within 10-20 seconds while in Fenix it drags on, sometimes indefinitely.
See video attachments.

Attached video chrome_cnn_3g_slow.mp4

Chrome loading https://www.cnn.com on a RogersInAbox "3g slow" throttled network.

The progress bar completes in about 18 seconds. (Note that the primary image does not even load).

Fenix nightly, 09/11/2024, loading https://www.cnn.com on the same RogersInAbox "3g-slow" configuration.

I had to trim the video to fit within Bugzilla file limits, but the progress doesn't actually complete even though all the visual content has has been loaded and displayed for quite some time.

I tried capturing profiles of the near-infinite progress bar, but when profiling so far I'm seeing it complete at about 34seconds, while the images are loaded at about 19 seconds. Not great, but this isn't the problematic scenario that I see in general, and in the videos.

https://share.firefox.dev/3ZfDWqu

I think good next steps on this one could be to find a scenario where multiple people can reproduce a large difference in progress bar times, Fenix to Chrome.
Perhaps https://www.cnn.com, current Fenix Nightly, with 3g-slow or 3g-fast is that scenario, but it's not clear.

With that determined, we can capture nsHttp:5 and related logs, as well as performance profiles, to understand what's happening.

See Also: → 1583222

I'm going to see if this is related to the class-of-service tailing that defers tracking requests.

Disabling tailing doesn't seem to resolve the endless progress bar that I'm seeing.
It does seem to affect android pageload tests in CI though, which I'll summarize in bug 1915866

Collecting some findings and patches of Kaya's

Browser Page Load Progress Bar Completion Comparison
https://docs.google.com/presentation/d/1dZldCss2hDTQO4S8MPgk801GFVnMIVGyDTIL2PgPlT4/edit#sl

And patches that adjust when the geckoview progress bar is completed: at MozAfterPaint and at DomContentLoaded.

I'm going to investigate what's in the document loadgroup and why those resources take 50+ seconds to load.

I've built a test page that highlights the different progress bar behaviours between Chrome Mobile and Fenix:

https://acreskeymoz.github.io/slow/slow_images.html

• There is a long running script that blocks DomContentLoaded (both browsers display the progress bar at about 25%)
• The page contains a medium size image and some larger ones which take multiple seconds to load (two below the fold)
• On DomContentLoaded and the first paint, Chrome completes the progress bar. Images are still loading. This is about 13 seconds before the onload event.
• Fenix waits until the onload event to complete the progress bar.

See attached videos. No network throttling required to reproduce.

Attached video fenix_slowpage_test.mp4

Fenix loading the test page.

Chrome loading the test page.

On desktop, as far as I can tell, both Chrome and Firefox run the throbber until the onload event is fired.

On mobile, I find Chrome's behaviour to give a much better user experience, especially on content-heavy sites on slower networks where the Fenix progress bar can run for over a minute, eg, cnn.

I propose that we try out completing the progress bar after the first MozAfterPaint following DOMContentLoaded (maybe nightly only).

If you're curious as to why Fenix displays the content much sooner on this site, it's because gecko crunches through the long running script, below, about 3x faster than Chrome.

   let n = 1000000000;
   let result = 0;
   for (let i = 0; i < n; i++) {
            result += Math.sqrt(i);
     }

I've updated the test site to output the duration of the script: https://acreskeymoz.github.io/slow/slow_images.html

Let's try a perfetto trace to verify the Chrome behaviour on the test page.

Flags: needinfo?(acreskey)

I haven't been able to figure out what Chrome is doing with respect to the Android progress bar from the perfetto trace
(One is here if anyone is interested).

But I've constructed a simpler site that demonstrates the behaviour of both browsers:
https://acreskeymoz.github.io/slow/slow_requests.html

Here’s the observed behavior:

  • DOMContentLoaded takes a bit over 5 seconds (due to a script loaded via slowfil.es).
  • At DOMContentLoaded/ document interactive, Chrome immediately completes the progress bar.
  • A new, slow-loading script (8 seconds) is dynamically added to the document.
  • Both browsers reach onload at ~16 seconds.
  • In Fenix, the progress bar completes only after onload.

This highlights a discrepancy in progress bar handling between Chrome and Fenix.

I think that for the mobile experience, completing the progress bar on the first paint after DomContentLoaded provides a better experience.

Flags: needinfo?(acreskey)

We can compare the behaviour of Fenix (left) to Chrome (right) on the slow request test site.

Kaya, unless there are objections can you make a variation of your earlier patches in which we complete the progress bar on the first paint after dom content loaded?
We can land this as nightly-only to give folks more of a chance to try it out.

Flags: needinfo?(kkaya)
Assignee: tchoh → kkaya
Flags: needinfo?(kkaya)
Priority: -- → P1

https://acreskeymoz.github.io/slow/slow_requests_async.html

Added a test in which the slow loading script after DCL is an async script.
We see the same behaviour -- Fenix waits for onLoad event to complete the progress bar while Chrome completes it on DCL / interactive.

The default value for Nightly is set to 2, which completes the page load progress bar at the first MozAfterPaint callback after DOMContentLoaded. The completion on the other channels are kept as it is.

We have a probe that records geckoview page load progress time, but it's not clear to me that values are recorded:
https://dictionary.telemetry.mozilla.org/apps/fenix/metrics/geckoview_page_load_progress_time

:acreskey, we have a stopwatch that's attached to this metric, that we start and stop according to the page load, here: https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/mobile/shared/modules/geckoview/GeckoViewProgress.sys.mjs#190-192

We start if off when the page load starts, here: https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/mobile/shared/modules/geckoview/GeckoViewProgress.sys.mjs#215

Then, we stop it at several places in GeckoViewProgress (page load finish, error case etc.), here's where a successfull pageStop might have happened that we stop the stopwatch with a successful page load state: https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/mobile/shared/modules/geckoview/GeckoViewProgress.sys.mjs#473

Attachment #9442296 - Attachment description: WIP: Bug 1906726 - Add a config to control the page load progress bar completion on Android. → Bug 1906726 - Add a config to control the page load progress bar completion on Android.

(In reply to Kayacan Kaya [:kaya] from comment #33)

:acreskey, we have a stopwatch that's attached to this metric, that we start and stop according to the page load, here: https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/mobile/shared/modules/geckoview/GeckoViewProgress.sys.mjs#190-192

We start if off when the page load starts, here: https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/mobile/shared/modules/geckoview/GeckoViewProgress.sys.mjs#215

Then, we stop it at several places in GeckoViewProgress (page load finish, error case etc.), here's where a successfull pageStop might have happened that we stop the stopwatch with a successful page load state: https://searchfox.org/mozilla-central/rev/d1e731d931b7b46237175de1701849a7cf5c8579/mobile/shared/modules/geckoview/GeckoViewProgress.sys.mjs#473

I don't think it's necessary to change the glean stopwatch, since, from what I can tell, it's tracking the document pageload (i.e. leading to onload event).

Blocks: 1937907
Pushed by kkaya@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/18407fa1f137 Add a config to control the page load progress bar completion on Android. r=geckoview-reviewers,ohall
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 136 Branch
Regressions: 1941099
Depends on: 1960758
Duplicate of this bug: 1773543
Duplicate of this bug: 1656386
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: