Preload while in inactive tab [Solved]

We have a growing number of assets in our browser game and one of the complaints I received recently is that if the player opens the game in one tab and then switches to another tab while the game is still loading, the game stops loading until the player switches back.

Based on some forum searching, I’m guessing this is due to OpenFL using requestanimationframe, which does not fire when the browser tab is inactive.

The only way I can think to get around this is to set the embed flag to false for all assets and manually load them using a Timer instance, but I don’t know if that’s the best approach.

Is there another way I can have the assets continue to load while my game is in an inactive browser tab?

Well, there goes my Timer hack plan… found out after many runtime errors that text files loaded asynchronously aren’t cached in OpenFL orz

Used a web worker to fix my issue :smiley:

3 Likes