question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance degradation when navigating to a page and going back several times

See original GitHub issue

Description

Each time a page navigates to another created by a dependency service as a result of a call to Shell.Current.GoToAsync a new instance of that page is created and the time to create and/or navigate to that page is incrementally extended.

The attached sample project demonstrates this behavior.

The project is standard MAUI template app with a MainPage and an additional NewPage with some controls on it to speed up the effect of delaying. The idea is that the MainPage navigates to the NewPage and then the NewPage returns back to MainPage in a loop and the loading time of the NewPage is measured and displayed. This loading time get gradually increased.

Timers have been added to MainPage and NewPage. When the timer event occurs in the MainPage the current time is taken and navigation to the NewPage is initiated. When NewPage finishes loading, it displays how long it took to load. The timer in NewPage then triggers a “back” action by executing Shell.Current.GoToAsync(".."). The MainPage timer starts again and the loop continues infinitely.

You can notice that the load time (in milliseconds) presented in NewPage increases with each iteration. After 20-30 iterations, the loading time becomes a few seconds and continues to grow.

This behavior is observed on all three tested platforms – iOS, Android and Windows.

No latency increase is observed when NewPage is added to the dependency service as a AddSingleton<NewPage>() and progressively increasing latency is experienced when added as a AddTransient<NewPage>().

Steps to Reproduce

Please run the attached project and click the button “Start the loop” then observe the number in the page that shows up.

Link to public reproduction project repository

https://github.com/gkamenov/MauiBug

Version with bug

7.0 (current)

Last version that worked well

7.0 (current)

Affected platforms

iOS, Android, Windows

Affected platform versions

iOS 14.2 and up, Android 8 and up, Windows build 22621.1105

Did you find any workaround?

No workaround so far.

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Reactions:3
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
matteo-convertcommented, Jan 27, 2023

I think this is might be related to #10578 and #12930

There is definitely tons of UI bits getting stuck in the memory, even though the overall memory size rises only slightly. I’m not sure if this can lead to such significant performance degradation, but I tried the same thing by pushing the page the old school way:

await Navigation.PushAsync(new NewPage());
await Navigation.PopAsync();

The problem is exactly the same - performance degrades and memory increases, so I wouldn’t suspect some Shell routing problem.

if i can help you, the shell is not the problem MAUI is the problem, i’ve track all my page destruction / ViewModel / Object, create my own shell, use syncfusion components and application still bug after navigate between pages, all the time the same problem, more and more slow for no reason because the memory usage don’t increase (you can see if you attach your debugging on android Studio), and the only thing they do is send problems that prevent production in Backlog milestone

1reaction
dpjha84commented, Apr 4, 2023

When will this fix be available to use?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Browser Back/Forward Caches and their Benefit to Web ...
Once Back/Forward cache rolls out for a browser, you might see a drop in page loads from that browser (since those navigation types...
Read more >
Navigation Timing Level 2
This specification defines an interface for web applications to access the complete timing information for navigation of a document.
Read more >
How to force reloading a page when using browser back ...
Since performance.navigation is now deprecated, you can try this: ... most up to date way reload page if the user clicks the back...
Read more >
Back/forward cache - web.dev
Back /forward cache (or bfcache) is a browser optimization that enables instant back and forward navigation. It significantly improves the ...
Read more >
PerformanceNavigationTiming: type property - Web APIs | MDN
You can use this property to categorize your navigation timing data as each of these types will have different performance characteristics.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found