We will learn the best tips & tricks to improve performance of canvas apps. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in the field of Power Apps.
Enhance / Speed Up the OnStart property
We will need to use the ClearCollect function to cache data locally if it doesn’t changes during the user session. Along with that, it is also important to use the “Concurrent” function to load data sources simultaneously; this can cut the amount of time an app needs to load data in half.
Consider the below example where we load an application with & without concurrent function.
Without the Concurrent function, the following formula loads each of four tables one at a time:
ClearCollect( Product, ‘[SalesLA].[Product]’ );
ClearCollect( Customer, ‘[SalesCA].[Customer]’ );
ClearCollect( SalesOrderDetail, ‘[SalesL7].[SalesOrderDetail]’ );
ClearCollect( SalesOrderHeader, ‘[SalesL9].[SalesOrderHeader]’ )
On monitoring the performance in the developer tools, we can observe that each collection is processed sequentially on after the other.
With the Concurrent function, the following formula loads each of four tables parallelly in a single operational cycle:
Concurrent(
ClearCollect( Product, ‘[SalesLA].[Product]’ ),
ClearCollect( Customer, ‘[SalesCA].[Customer]’ ),
ClearCollect( SalesOrderDetail, ‘[SalesL7].[SalesOrderDetail]’ ),
ClearCollect( SalesOrderHeader, ‘[SalesL9].[SalesOrderHeader]’ ))
You can enclose the same formula in the Concurrent function to reduce the overall time that the operation needs as shown above. On monitoring the performance in the developer tools, we can observe that each collection is processes concurrently.
Add a limit on data connections
As a recommendation, one canvas application should not have more than 30 connections present in it. Canvas application prompt new users to sign in to each connector, so every extra connector increases the amount of time that an app needs to start. As an application runs, each connector requires memory, CPU resources and network bandwidth when an app requests data from that source.
You can use the Developer Tools on Microsoft Edge or Google Chrome for measuring your app’s performance.
Delegation usage
Wherever possible, use the functions that delegate data processing to the data source instead of retrieving data to the local device for processing. If an application requires to process data locally, an app’s operation requires much more processing power, memory, and network bandwidth, especially if the dataset is large.
For an example of delegable functions, consider an CRMCrateID column defined as the Number data type in a list created using Microsoft Lists. Formulas in the following example will return the results as expected. However, the first formula is delegable while the second is non-delegable.
Formula | Delegable? |
---|---|
Filter ('List data source', CRMCrateID = 007) | Yes |
Filter(`List data source', CRMCrateID =" | No |
Click on the given link to learn more about delegation in Canvas App – https://www.crmcrate.com/power-apps/understanding-the-delegation-warning-in-canvas-app-with-examples/
Republish an application on regular interval
Power App developer / makers are encouraged to publish their apps regularly. Because the Power Apps platform is continuously optimized and deployed, your app is regenerated within the latest platform optimizations when you republish it.
Reduce the number of controls
As a recommendation, one canvas application should not have more than 500 controls present in it. Power Apps generates an HTML document object model (DOM) to render each control. The more controls you add, the more generation time Power Apps needs.
In addition, you might want to reduce the number of control types on the same screen like some controls such as PDF viewer, data table, and combo box pull in large execution scripts and take longer to render.
Cache the data present in lookup
Use the “Set” Power FX function to cache data from lookup tables locally to avoid repeatedly retrieving data from the source. This method optimizes performance if the data probably won’t change during a session.
As shown in the following example, the data is retrieved from the data source at once and then referenced locally until the user closes the Canvas Application.
Set(CustomerOrder, Lookup(Order, id = “00-91-CRMCrate”)); Set(CustomerName, CustomerOrder.Name); Set(CustomerAddress, CustomerOrder.Address); Set(CustomerEmail, CustomerOrder.Email); Set(CustomerPhone, CustomerOrder.Phone);
This method is more useful for data such as contact information, default values, or user information that doesn’t change frequently.
Operating with large datasets
Use data sources and formulas that can be delegated to keep your apps performing well while users can access all the information they need and avoid hitting the data row limit of 2,000 for non-delegable queries.
Click on the given link to learn more about delegation in Canvas App – https://www.crmcrate.com/power-apps/understanding-the-delegation-warning-in-canvas-app-with-examples/
Prevent repeating the same formula in multiple places
If multiple properties execute the same formula especially when it is complex then consider setting it once and then referencing the output of the first property in subsequent ones.
For example, don’t set the DisplayMode property of controls Fruit, Vegetable, Roots, Tree to the same complex formula. Instead, set Fruit’s DisplayMode property to the complex formula, set Vegetable’s DisplayMode property to the result of Fruit’s DisplayMode property, and so on for Roots & Tree.