Add ability to manually download assets to local storage or memory

Roblox games are using more and more high memory assets and currently there is no memory management system accessible to developers, this is bad. There needs to be a way for developers to choose which assets are currently loaded in memory, and a way for developers to download assets from Roblox and cache them locally, allowing for quicker join times, much less network usage and better optimization for mobile devices

Example use case would be caching guns in Phantom Forces, players shouldn’t have to download every mesh in the game every time they play. When I play this game I need to wait a few minutes for all the gun meshes to load in, and because there is no memory management system players get put into a game with a bunch of unloaded meshes, very bad UX

local AssetService = game:GetService("AssetService")

AssetService:DownloadAsset({
    Name = "Ford_Camaro", --"File name" used to load/unload from memory
    ID = "rbxassetid://123456789",  --Allow iteration on mesh assets
    Cache = true, --Save this asset to hard drive, useful for large meshes and audio
})

AssetService:LoadAsset("Chevrolet_Mustang")
AssetService:UnloadAsset("Chevrolet_Mustang")
4 Likes

I may have misunderstood your request but it seems like you want a way to install assets on player’s devices for faster loading times.

This is infeasible.

In games outside of Roblox the meshes, sounds and textures and such of the game are downloaded to your computer. While in Roblox you do get the textures and such used by the engine installed, you don’t install the assets of every single game you join on Roblox.

It is infeasible for Roblox to install every single asset on your computer so Roblox downloads them on a need-to-know basis.

You can use ContentProvider:PreloadAsync to preload assets.

When you load an asset (either by it being lazy loaded or via ContentProvider | Documentation - Roblox Creator Hub), it is cached in the http cache on the player’s local device. Last I checked this cache has a size of 1+ GB on desktop. If you rejoin the game on the same device assets should load much quicker because they come from the cache. (assuming no other assets knocked the items out of the cache)

I don’t think you’d really want to manage storage as a developer (and I don’t really trust most developers to manage this well, how do you balance storage size between that many games?), just use PreloadAsync and let the engine handle the rest.

4 Likes

Personally, I think we should have the option to manually unload images, sounds, etc, but the engine should also unload assets that haven’t been used in a while automatically.

For example, in our game, we have an intro UI with some images. These images are not displayed anywhere else in the UI and the intro UI never comes back after you click play. There is no reason for those images to be stored in the cache once that UI goes away.

Perhaps removing assets from the cache could be tied to a Object.OnDestroyed event in some way.

4 Likes

as far as I’m aware, UI assets (images) get deloaded when they are not visible or have transparency of 1