Forum Xamarin.Forms

Slow graphic performance in a ContentPage when navigated through 3-4 views

pacomaralpacomaral Member ✭✭
edited November 2019 in Xamarin.Forms

I'm developing an application which has 6-7 pages. I noticed that when it has already been navigated between 2-3 pages, the performance is kinda awful on old devices.

Let's say I have this Navigation:

Page 1 -> Page 2 -> Page 3 -> Page 4

What I'm saying is that in that point, the performance of the Page 4 is bad (animations are not fluid, listview scroll is awful...). However, if I set the page 4 my first page (without having to navigate through the others), it is working as expected. I guess it is normal to lose some performance by the other way, but I don't know if I'm doing something wrong because it works too bad.

I'm using the prism navigation service, and I'm navigating by calling the NavigateAsync method with the name of the content pages, and setting the property to modal. My knowledge of the navigation in Xamarin Forms is basic (and even more with Prism) and I would like to know if I'm missing something.

I also noticed with the View Hierarchy, that when I navigate to the Page 4, there are all the other pages rendered too. Is this a normal behavior?

Thanks in advance.

Posts

  • JohnHardmanJohnHardman GBUniversity mod

    @pacomaral

    The older devices are probably limited on available memory. As you navigate deeper into your page hierarchy, your app will be using more memory. If you want better performance on old devices, you may need to reorganise your navigation and page design to avoid having too many pages open at the same time. You can also look at optimising memory usage on each page, including releasing resources when a page is not visible because another page has been opened over the top, as well as using WeakReference etc.

    If you have access to a profiler, use that to see what is happening with memory usage as you navigate your app.

  • pacomaralpacomaral Member ✭✭

    @JohnHardman said:
    @pacomaral

    The older devices are probably limited on available memory. As you navigate deeper into your page hierarchy, your app will be using more memory. If you want better performance on old devices, you may need to reorganise your navigation and page design to avoid having too many pages open at the same time. You can also look at optimising memory usage on each page, including releasing resources when a page is not visible because another page has been opened over the top, as well as using WeakReference etc.

    If you have access to a profiler, use that to see what is happening with memory usage as you navigate your app.

    Yes, I guess that should be the problem. I just asked to find out if I was doing something wrong. Anyway, I checked out the memory usage on both cases (navigate first, or navigate after 2-3 pushes), and I don't see much difference between them. It's using 16% of allocated memory when pushing first, and 22% on the other case.

    Related to releasing memory, I have been doing that when I pop pages, but I don't really know what could I release when I just want to push another page, not popping. However i'm not deeping too much here, because I can't use the Xamarin Profiler as I don't have the enterprise version, and I have to do it with Android Device Monitor.

  • JohnHardmanJohnHardman GBUniversity mod

    @pacomaral

    Also, are Page1, Page2 and Page3 still doing work when Page4 is displayed? Are they handling events, MessageCenter messages, timers etc? If so, can any of those be turned on in OnAppearing() and off in OnDisappearing() ?

Sign In or Register to comment.