cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
hantsjoel
Resolver II
Resolver II

Power apps Studio freezes when editing OnStart

Hi all,

 

I have built an enhanced version of the template Onboarding App with additional functionality for Line Managers and Admins. The app has a very complex OnStart property, which sets various variables, created a number of collections and navigates the user to the appropriate screen.

 

Now, when I try to edit the OnStart property Power Apps Studio will freeze, I expect due to the complexity. I have usually been able to workaround this by writing formulas outside of power apps and pasting them into OnStart.

 

However, I now need to edit one of my OnStart ClearCollects. Editing it directly freezes the app, and the cut and paste trick is not working either. Studio won't freeze, but all controls become unselectable, datasources won't refresh and the app won't save. All I can do is refresh the page and lose the edits to OnStart.

 

Has anyone experienced this before? If so, does anyone know of a fix?

 

Many thanks,

Joel

1 ACCEPTED SOLUTION

Accepted Solutions
GarethPrisk
Super User II
Super User II

The simplest fix will be to move the long-running code out of the app's onStart and into a separate function.

Without seeing the code, I cannot comment on whether it is too long, too complex, etc.

 

Try this

  1. Add a Landing Screen
    1. Your app will always 'land' on the top-most screen in the studio
    2. Add a new screen, move it to the top
  2. Add a Button control
    1. Add your long-running code, and the navigation formula to it
  3. Update the Screen onVisible to Select(Button)
  4. Play the screen
    1. It will select the button and trigger the function
    2. You'll be able to more clearly understand how long the process is taking, and/or triage bugs independently of the app's onstart

 

In my experiences, the App OnStart can potentially become too overloaded and things won't run properly (studio or player). This approach can at least allow you to separate quick/instant stuff (like simple variables or non-external data collections), and the longer running stuff (data collections, long-running ForAlls, etc.) for when the app itself has initialized.

 

Are you doing best practices in your calls?

  • Filtering/delegating
  • Concurrent functions

The approach above can be polished up to avoid the button being clicked every time you open the screen in the studio, and those controls can be hidden, as well. Include a simple loading animation to let the user know that stuff is happening, for example.

View solution in original post

2 REPLIES 2
GarethPrisk
Super User II
Super User II

The simplest fix will be to move the long-running code out of the app's onStart and into a separate function.

Without seeing the code, I cannot comment on whether it is too long, too complex, etc.

 

Try this

  1. Add a Landing Screen
    1. Your app will always 'land' on the top-most screen in the studio
    2. Add a new screen, move it to the top
  2. Add a Button control
    1. Add your long-running code, and the navigation formula to it
  3. Update the Screen onVisible to Select(Button)
  4. Play the screen
    1. It will select the button and trigger the function
    2. You'll be able to more clearly understand how long the process is taking, and/or triage bugs independently of the app's onstart

 

In my experiences, the App OnStart can potentially become too overloaded and things won't run properly (studio or player). This approach can at least allow you to separate quick/instant stuff (like simple variables or non-external data collections), and the longer running stuff (data collections, long-running ForAlls, etc.) for when the app itself has initialized.

 

Are you doing best practices in your calls?

  • Filtering/delegating
  • Concurrent functions

The approach above can be polished up to avoid the button being clicked every time you open the screen in the studio, and those controls can be hidden, as well. Include a simple loading animation to let the user know that stuff is happening, for example.

View solution in original post

Thank you, @GarethPrisk. This is a great tip!

 

The problem actually persisted even after copying all the OnStart formulas onto a button, so I tried splitting it out onto multiple buttons and in the process discovered a global variable that was throwing an 'incompatible type' error. Curiously, when the Set formula was on OnStart it wasn't throwing the error and still allowed OnStart to run.

 

After removing the Set function and placing it elsewhere in the app, I was then able to edit the rest of the formulas with no issue.

 

Many thanks for your help. I will use your suggested method from now on.

 

Joel

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (38,235)