Performance degradation when navigating to a page and going back several times
See original GitHub issueDescription
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:
- Created 8 months ago
- Reactions:3
- Comments:8 (1 by maintainers)
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
When will this fix be available to use?