Add Granular Preloading

Currently preloading game assets stores it all in memory (RAM).
With a case like Phantom Forces where we have gigabytes of mesh assets, preloading all this data is starting to become a problem.

We want to preload our gun meshes but we don’t want them to hang around in memory.
We’d like the ability to have files cached in the file system on the player’s computer so they can load faster on demand, instead of Roblox streaming it over the internet whenever we need it or have it hogging up active memory resources.

45 Likes

My team has needed a feature like this on multiple occasions. One case was with complex custom terrain generation and destruction in an open world. Our other case was more along the lines of what Lito described. :+1:

5 Likes

Are you sure Roblox doesn’t already temporarily cache assets on the players’s computer? From my quick test just now it took over 10 seconds to preload PF the first time. The next two tries took less than 5 seconds.

I also don’t know why you’re preloading hundreds of weapon meshes if you’re only going to see a handful of them throughout an average play session. Just let the mesh(es) and sounds for a specific gun load in dynamically when a player spawns in with it.

5 Likes

Roblox does cache some assets like meshes and unions on your hard drive, but this is different than preloading. When you preload an asset, it is loaded into memory and held there until the game is closed/reset, or, whenever Roblox decides to unload it otherwise (afaik never, but, I wouldn’t really know)

The problem that the post asks for a resolution on isn’t the speed assets load at, it’s the RAM usage with preloaded assets.


I think that ideally preloading should not be greedy, if it is, if mesh or union data is cached already (or can be), then it should be unloadable by the engine even if the developer asked that it be preloaded.

This could cause bad load times on devices with slow drives or limited space, but, RAM is already a limited space far more than disk, and falling back to disk only needs to happen if available RAM doesn’t suffice.

The next question to ask is whether or not there is a significant performance impact to holding gigabytes of unused assets in memory. Lito was pretty vague when he said the preloading was “starting to become a problem”. The load time is an obvious problem but maybe they’ve also run into a performance problem too. There are probably conditions where Roblox will unload assets if it’s running low on memory.

Short term solution to load time and RAM: Only preload weapons that the other players have equipped (Primary, secondary, melee, grenade) + the most common assets (UI stuff).

The problem isn’t performance or speed, those are pretty much as fine as they can be, RAM is fast and cheap, the only performance cost you’re ever going to have is GC, but, mesh data isn’t a thing that gets GCed as far as I am aware.

The problem, again, is RAM usage. Not everybody has 8 or 16 GB of RAM, mobile devices usually only have 1 or 2 GB of RAM, and Roblox is very aware of that already. Like Lito said, they have gigabytes of mesh data, preloading all of that on a device with low RAM is not possible, and having Roblox hogging a bunch of RAM isn’t feasible for some people either.

If Roblox is greedily hogging or trying to reserve a bunch of RAM like it sounds like Lito is suggesting, that’s a problem because it limits what devices can join a game or you sacrifice load speeds in a not so smart way.

On Windows its the most problematic from what I’ve experienced, it leads to hard crashes on programs (usually the program taking all the RAM but surprisingly not always). It can also result in system processes crashing on Windows, and can in rare cases lead to memory corruption, which can then lead to BSODs, which can lead to drive writes getting corrupted, and plenty of other not so fun but rare stuff.

On Android it results in the app crashing.