Starting a Unity WebGL app without blocking the main thread (for animations)

Hi,

I was wondering if it was possible to load unity without blocking the main thread of the browser tab.
For instance, when our app loads, the css loading animation (not a bar) will freeze when the app is ‘starting’ after the data has finished downloading.

This will cause users with lower end devices to think the app is freezing or not working.
Clicking buttons on popups, and other default browser behavior, will also not work in this tab.

Is it possible to keep the main thread of a tab running while the unity app is starting?

Unity is the main thread. :slight_smile:
And that’s the only thread there is in a Unity web app for the time being.

Hence why optimizing Unity builds for the web is an art form, and an arduous amount of work that few expect.

The number one thing you should do is to add a practically empty scene as the first one in the build list. Make sure this scene doesn’t load anything but the most important assets, such as a “Loading” image. You want that scene to load asap, and then you can either change to the actual first scene or async load your resources, do your webrequests, load addressables, additively load scenes or instantiate prefabs.

That way you can at least have Unity render something, it may still look frozen but it ought to still render a frame here and there rather than being a complete still image.