Best practices to increase page loading performance

MEJMEJ DEMember ✭✭
edited January 2018 in Xamarin.Forms

I have an app that contains a page to display some product data in a devexpress grid. There ist a decent amount of data, which causes the page to load very slow when calling Navigation.PushAsync(_ProductDialog);. Is there an option to preload or pre-render the page? Loading takes around 5 seconds on the first call and actually causes the app to crash some times.

To be more precise: the grid contains 250 items in 2 columns. The first time loading the dialog is very slow, but the following launches are usable.

Best Answer

Answers

  • FishDevFishDev USMember ✭✭

    @ShantimohanElchuri said:

    @MEJ said:
    I have an app that contains a page to display some product data in a devexpress grid. There ist a decent amount of data, which causes the page to load very slow when calling Navigation.PushAsync(_ProductDialog);. Is there an option to preload or pre-render the page? Loading takes around 5 seconds on the first call and actually causes the app to crash some times.

    To be more precise: the grid contains 250 items in 2 columns. The first time loading the dialog is very slow, but the following launches are usable.

    Are you populating the Grid in the main thread? If it is taking long time to buid the Grid then it should be done in a background thread. Generally such things are to be done in OnPageLoaded event.

    This sounds like the most likely cause. By chance are you instantiating the data for the Grid in the constructor of the Page? This will block the UI thread and make the page slow to load. I use MVVM for my development and have this kind of data available in the ViewModel which I think bind to from the view so that it's non-blocking. If you don't want to go the MVVM route, you could ovveride OnAppearing in the page that takes a long time to load and perform your data related activity there (might need to mark the method async). This shouldn't block.

  • MEJMEJ DEMember ✭✭

    Thanks @FishDev that's what I did and it definitely runs faster now.

Sign In or Register to comment.