luxeengine / alpha

alpha - deprecated 2015~2016. unrelated to the new engine! view the new engine here - https://luxeengine.com/
MIT License
565 stars 74 forks source link

Parcels; going on background on web pauses loading #290

Open smvilar opened 9 years ago

smvilar commented 9 years ago
ruby0x1 commented 9 years ago

Would you mind elaborating what you mean?

smvilar commented 9 years ago

Sure.

When loading assets, a parcel will pause the process when switching to another browser tab. That means I need to stay on the tab while the game loads to see any progress.

ruby0x1 commented 9 years ago

Ah background tab I see I see.

This isn't intentional but it's how the main loop works on the browser, it is using requestAnimationFrame which potentially gets slowed or suspended entirely when backgrounded. Currently the Promises are stepped by the main loop, which is what the loading would use which is why they're paused that way.

I'll look into it using setImmediate/setTimeout - but I will be careful with this causing state problems. For example, if you do actually pause the loop manually when backgrounded or losing focus, you wouldn't want the promises controlled by the browser - and just arriving when things aren't supposed to be happening.

Thanks for the report!