March 19, 2024

SamTech 365

PowerPlatform, Power Apps, Power Automate, PVA, SharePoint, C#, .Net, SQL, Azure News, Tips ….etc

Power Apps Performances’ optimisation – App OnStart

The second article in the Series of PowerApps Performances’ Optimisation will be dedicated to the App.OnStart event.

This Particular event is very handy when it comes to initialising your application variables and collections. In most cases, I’ve seen developers using this event to load the required data collections and entities hoping that this will speed up the rest of the application.

Why you should NOT load your data in the App. OnStart ?

If you have a complex application which might use a large data source, starting to load large amount of data and do all sort of complex calculations in the App . OnStart event, will keep your users stuck in the boring loading screen, which might put users off using the application.

This is the first screen your users would see each time they use your application.

Hoping to overcome the 2K Rows Limit ?

Another big driver for certain “Developers” to load data in the App.OnStart Event is the hope to over come the 2000 Rows limit that PowerApps imposes on us.

Developers might want to Create different collections of 2K Rows each, and merge everything in one massive collection.

The merged collection will be used in the sub screens for Galleries, filters …etc.

So what ?

Well, if you “Develop” like this, you will have the following challenges:

  1. The Big collection can become obsolete while the users are navigating your application, especially if they leave the app open for a long time.
  2. Also under the obsolete hat, users might work with a copy of the data, not the data straight from your back end, good luck managing concurrent data write backs.
  3. The need to refresh the big data collection would mean having to go through the same performance impacts (wait time) your users had to face initially (when your app was loading)

Users will access your App to do just one specific task

No need to worry about all the data required for all the screens in your App.

Most of the time, users will come to your PowerApps Application to perform a specific task, and are not going to spend a day navigating all the screens and checking each button of your application (Unless, you are trying to create the next Twitter or Facebook with PowerApps lol).

I would suggest you load the data required in each screen as the users are accessing it, instead of everything loaded in the App.OnStart.

The solution

Very simple !

  • Avoid loading your data in the App OnStart if it is absolutely necessary.
  • Instead, use the On Visible event in the first screen to implement logic.
  • Load the required data in each screen as the users access them.
  • Dispose of temporary collections using the Clear or Set(CollectionXYZ, Blank()) to dispose of this data from memory.

 

812