I have a loading screen for my game that shows how many assets are stills remaining, and for that I use ContentProvider:PreloadAsync() on ALL workspace descendants.
The issue I’m having is, when I open the Developer Console, there are a lot of errors like this: ContentProvider:PreloadAsync() failed for rbxassetid://00000
Is there a way that I can make these errors stop showing, or do I need to hunt for every single asset that is generating a error in my game and investigate why? I would like to keep the console clean on the client-side.
Errors screenshot
Part of the code
local queue = game.ContentProvider.RequestQueueSize
local ContentProvider = game:GetService("ContentProvider")
[...]
local assets = {}
wait(10)
for i,v in pairs(game.Workspace:GetDescendants()) do
table.insert(assets,v)
end
for i = 1, #assets do
local asset = assets[i]
local frame = loadgui.Frame
local indicator = frame.IndicatorText
ContentProvider:PreloadAsync({asset})
local progress = #assets - i
indicator.Text = "Loading Assets... (" .. progress ..")"
end
Happening because you’re using someone else’s meshes which they happened to archive. Easy way to make the errors stop showing is to not use someone else’s work. If you need to pinpoint which ones, test in Studio mode - pretty sure clicking on a load error will select the object for which the loading error was generated for.
Regarding your use of PreloadAsync: you should never be using PreloadAsync on the descendants of the workspace. First: PreloadAsync automatically passes in the descendants of an object, so you should never do descendant collection yourself. Second off, that’s not the point of PreloadAsync.
Preloading everything is the same as preloading nothing. At that point, you might as well just misuse RequestQueueSize instead. It only lets you know how many assets are queued for download but says nothing about their readiness or if they’ve been (successfully) downloaded. It’s also arbitrary so it can increase and decrease when new assets are introduced into the DataModel. Would certainly be a “better” misuse of ContentProvider if you ask me.
If I use RequestQueueSize without using PreloadAsync, will it return how many assets are still loading in the game? Or is there any better way to determine how many assets are still loading?
RequestQueueSize gives the number of items in ContentProvider 's request queue that are waiting to be downloaded.
Items are added to the client’s request queue when an asset is used for the first time or ContentProvider:PreloadAsync is called.
Developers are advised not to use RequestQueueSize to create loading bars. This is because the queue size can both increase and decrease over time as new assets are added and downloaded. Developers looking to display loading progress should load assets one at a time (see example below).
So to clarify: no it won’t, because RequestQueueSize doesn’t say anything about your game’s loading other than how many assets are queued for the client to download from the website. There aren’t other ways to check loading processes: those happen in the background.
ContentProvider’s real only developer-facing purpose is to make the client prioritise the download of assets that you’d like a client to see immediately. PreloadAsync will push an asset to the front of the queue (and, if it wasn’t used before, add it in) so that it’s one of the first assets downloaded. This is good for making items like main menu assets available right as the player joins while the rest is streamed in the background.