7 min readRishi

Canvas Apps: Concurrent() Is How OnStart Stops Feeling Stuck

Canvas Apps: Concurrent() Is How OnStart Stops Feeling Stuck

OnStart that calls four data sources one after another makes the user stare at a spinner for the sum of four round trips. Those calls usually do not depend on each other. The account list does not need the choice column metadata. The current user's bookings do not need the product catalog. Concurrent() runs them together and finishes when the slowest one finishes, not when all of them have taken turns.

Concurrent(
    ClearCollect(colAccounts, Accounts),
    ClearCollect(colProducts, Products),
    Set(varMe, User())
);
Set(varReady, true);

That is the pattern for independent work: one Concurrent, then a flag. Everything after the closing parenthesis can assume the collections exist. Everything inside must be safe to start at the same moment.

varReady is the flag the first screen checks. Until it is true, show a skeleton, not a gallery bound to a collection that is still empty. An empty gallery that fills in later looks like "no rows," and people tap New.

Independence is the only rule

A call is safe to run beside another when it does not read a variable or collection that the other call writes.

Safe togetherNot safe together
Two ClearCollects of different tablesA collect, then a Filter of that same collection
User() and a Dataverse listLookUp of a row whose id comes from the first LookUp
Several Set() of unrelated variablesPatch that must see the collection you are still loading

Power Apps does not topologically sort the arguments. It starts them. If formula B reads colAccounts while formula A is still writing it, B may see empty, partial, or complete. You will not get a compile error. You will get a first-screen gallery that is sometimes wrong.

The user's email is the usual dependency. You need varMe.Email before you can filter bookings. That filter stays after the Concurrent, or it becomes its own second Concurrent once varMe exists:

Concurrent(
    ClearCollect(colAccounts, Accounts),
    ClearCollect(colProducts, Products),
    Set(varMe, User())
);
ClearCollect(
    colMyBookings,
    Filter(Bookings, OwnerEmail = varMe.Email)
);
Set(varReady, true);

The three independent calls overlap. The bookings call waits. Nesting Filter(Bookings, OwnerEmail = User().Email) inside the same Concurrent as Set(varMe, User()) does not make varMe available to the Filter. User() can go in the Filter directly if you do not need the variable for anything else. Using the variable before Concurrent has assigned it is the bug.

Do not put Patch or Navigate in Concurrent. Patch that needs a loaded collection races. Navigate that fires beside a collect races the screen against the data. Set the collections, then navigate. If the first screen does not need every table, Navigate first and load the rest on that screen's OnVisible.

Concurrent does not change the query

Concurrent does not raise the delegation limit. A Filter that cannot be delegated still returns a partial set, just sooner. If the gallery was wrong before, it is wrong faster now. Fix the filter — or move the query to a Dataverse view — before you celebrate the spinner. The rules are the same ones in delegation warnings.

It also does not make a non-delegable ForAll cheaper. Parallelism does not forgive a loop that Patches a hundred rows on every launch. Load the rows. Patch when the user acts. OnStart that writes is a different class of problem than OnStart that reads slowly.

Collections are still in-memory copies. Concurrent that ClearCollects four large tables still pays four payloads and still goes stale when someone else edits Dataverse. If the screen can bind to the data source with a delegable Filter, skip the collection. Collections vs Dataverse is the decision; Concurrent is only for the copies you have already decided to keep.

First screen vs later screens

OnStart runs once per session. Stuffing every table the app might need into that Concurrent makes the launch wait on screens the user may never open. Split by when the data is first needed.

The first screen needs varMe, the accounts the gallery shows, maybe a settings row. Put those in OnStart. The product catalog used on screen three can load in that screen's OnVisible:

If(
    IsEmpty(colProducts),
    Concurrent(
        ClearCollect(colProducts, Products),
        ClearCollect(colPriceLevels, PriceLevels)
    )
)

OnVisible on a screen that opens a form is the other place Concurrent earns its keep. Load the record, the related contacts, and the choice labels together. The form's Item can bind immediately if you already have the record. The related gallery waits on its own collection. Users forgive a related list that fills in. They do not forgive a form that takes three seconds to show the name.

If(IsEmpty(...)) on OnVisible is there so a user who navigates away and back does not pay twice. It is also a footgun: if the collection is empty because the query returned zero rows, you will keep re-querying. Use a boolean (varProductsLoaded) when empty is a valid result.

If one of six OnStart calls is slow, pull it out of the varReady gate and let a second flag cover it.

When Concurrent is the wrong fix

Do not wrap work that must run in order. LookUp an id, then LookUp the row, then Set a record for the form — three sequential lines, not Concurrent.

Do not Concurrent a call you are about to ignore. Loading extra tables "in case we need them" is still a round trip.

Do not use Concurrent as a substitute for narrowing the query. A 2000-row ClearCollect of Accounts, overlapped with three other 2000-row collects, can still make a phone swap. Views, ShowColumns, and a Filter the user actually needs beat a wider Concurrent. The rest of that list is in canvas app performance patterns.

Do not Concurrent ResetForm or control Reset. OnStart runs before the first screen is a safe place to poke controls. That work belongs on OnVisible, and usually not in Concurrent.

Time the device, then look at the slow call

Studio monitor shows duration per formula. Use it to see whether the Concurrent arguments actually overlap, and which one dominates. Then time the same launch on a phone on the company network. The number that matters is the gap between icon tap and varReady. If one call is 2.4 seconds and the others are 200 ms, Concurrent turns sequential work into ~2.4 seconds. That remaining wait is not a Concurrent problem. Cache it, narrow it with a view, or stop loading it until the screen that needs it.

If monitor shows the arguments running one after another, you did not call Concurrent. You called three ClearCollects in sequence. The syntax is Concurrent(expr1, expr2, expr3) — separate arguments, not a block of semicolons inside one argument.

If a collection is empty after Concurrent and monitor shows a failed formula, Concurrent did not swallow the error. The other arguments may still have completed. Check Errors against that data source and confirm the user has permission in this environment.

  • Every Concurrent argument is free of the others' outputs.
  • Dependent Filters sit after Concurrent, or take User() directly.
  • A loaded flag gates galleries so empty does not mean "create."
  • No Navigate, no Patch, no control Reset inside Concurrent.
  • Delegation warnings on those Filters are gone, or accepted with a documented row cap.
  • First-screen data is the only data in OnStart. The rest is OnVisible with a loaded flag.
  • You have a device timing for launch-to-ready, and the slowest argument is the one you optimize next.

Concurrent is how independent reads stop queuing. It is not how a bad Filter becomes a good one, and it is not a reason to load the entire model before the first control paints.

Keep reading

Newsletter

New posts, straight to your inbox

One email when a new post goes up. Double opt-in, unsubscribe anytime. Not a daily digest.

Comments

  • No comments yet. Be the first.