NewGuy Posted August 14, 2016 Share Posted August 14, 2016 (Not sure if there is a better place to post but here it goes) Hello again, devs.This is a general question that I'd anyone to reply to mostly regarding when you load your assets. I'm interested to know if people mostly bulk load in some loading screen state or get clever and do on the fly loading (if this is even possible?) or even something like level to level asset loading/unloading. This may be a bit of an odd post but I'd really like to see how other get the job done, as at the moment I'm having performance issues which I'm fairly sure is due to how I load mine (one bulk load on a loading screen, then onLoadComplete I move on) Cheers Link to comment Share on other sites More sharing options...
mattstyles Posted August 15, 2016 Share Posted August 15, 2016 Highly dependent on the project. Easiest is to bulk load up front, but, if you need a lot it's going to take a while, at least, on the first load. You should try to ensure that as much as possible is cached so that at least subsequent visits to your page are quicker, app cache can be useful (but awkward) for platforms that support it but you can take easier methods such as stuffing data into local storage or a browser db, most likely you'll just be relying on standard browser cache for things. Financial Times even stuffed images into local caching and db storage, taking a hit on image decoding in browser but allowing an offline experience and giving them some control over when and what to load remotely (whilst possible, you have a different use-case so this probably isn't a good idea for you). After that I'd guess that level by level (if possible in your game) loading would be the next easiest, as it is the same procedure split in to chunks. General stuff gets loaded up front and specific stuff gets loaded at the start of a level. You may want to compromise your design so that each level isn't loading loads and loads of stuff i.e. limit the available tiles to make up the map or limit the amount of sounds etc etc. Loading stuff on the fly is tricky, you'd have to predict when you need stuff and, where possible, load that before it is required, not when it is required. This can be very tricky. There is the additional difficulty here that loading patterns and http access can slow down the JS thread, normally the load happens away from the thread but if you're doing any processing after or before loading then it could be a source of jank. For heavily chaotic games this may be near impossible but you may be able to bend your rules e.g. if you spawn entities in a fairly random manner then you could request the needed resources and limit spawning those entities until you have the resources, yeah, could get tricky. drhayes and NewGuy 2 Link to comment Share on other sites More sharing options...
carlosnufe Posted August 15, 2016 Share Posted August 15, 2016 As mattstyles says, one state to preload and cache your assets whether your project is not big. Otherwise, if it is big, you can create an state to handle the loads.. Just, quantify the time loading and decide to split in chunks or not. NewGuy 1 Link to comment Share on other sites More sharing options...
NewGuy Posted August 15, 2016 Author Share Posted August 15, 2016 @mattstyles @carlosnufe Awesome repl! You really went above and beyond to explain which is great. Based on what you've said I don't think the issues I'm having might not be related to a overloaded cache or anything. I have a lot of audio files I'm autodecoding onload at the start of my game and when I prevented the audio loading the performance went back to normal. What I don't understand is why, even when audio isn't always playing, would loading / decoding audio cause my game to be permanently jittery? The issue occurs on an iPad 4 specifically if this gives any extra insight? (Devices such as Samsung Tab S2 for example perform great) pps. I'm using a Cordova setup for iOS / Android dev Link to comment Share on other sites More sharing options...
Recommended Posts