ContentProvider
Service that is used to load content, or assets, into a game.
Memory category | Instances |
---|
Member index 17
Removed member index 9
History | Member | |
---|---|---|
642 | CalculateNumTrianglesInMesh(meshId: string): int | |
642 | CalculateNumTrianglesInMeshSync(meshId: string): int | |
646 | GetDetailedFailedRequests(): Array | |
311 | GetFailedUrls(): Array | |
66 | GetRequestQueue(): Array | |
66 | GetRequestedUrls(): Array | |
311 | SetAssetUrl(url: string): void | |
311 | SetCacheSize(count: int): void | |
311 | SetThreadPool(count: int): void |
Description
Service that loads content (assets) into a game.
Roblox servers stream all assets to the client at runtime: objects in the Workspace, mesh assets, texture assets, etc. Assets such as mesh visual data, textures, decals, and sounds are streamed in as required, regardless of whether Streaming is enabled.
In some cases, this behavior is undesirable, as it can lead to a delay before the content loads into the experience.
ContentProvider
lets you preload assets into an experience using the
ContentProvider:PreloadAsync() method. You might want to display a
loading screen, preload critical assets, and only then allow the player into
the experience.
Best Practices for Preloading
- Only preload essential assets, not the entire Workspace. You might get occasional pop-in, but it decreases load times and generally doesn't disrupt the player experience. Assets that are good candidates for preloading include those required for the loading screen, the UI, or the starting area.
- Let players skip the loading screen, or automatically skip it after a certain amount of time.
History 78
- 646 Remove GetDetailedFailedRequests
- 645 Change Parameters of AssetFetchFailed from (assetId: Content) to (assetId: ContentId)
- 645 Change Parameters of UnregisterEncryptedAsset from (assetId: Content) to (assetId: ContentId)
- 645 Change Parameters of RegisterSessionEncryptedAsset from (contentId: Content, sessionKey: string) to (contentId: ContentId, sessionKey: string)
- 645 Change Parameters of RegisterEncryptedAsset from (assetId: Content, encryptionKey: string) to (assetId: ContentId, encryptionKey: string)
- 645 Change Parameters of Preload from (contentId: Content) to (contentId: ContentId)
- 645 Change Parameters of GetAssetFetchStatusChangedSignal from (contentId: Content) to (contentId: ContentId)
- 645 Change Parameters of GetAssetFetchStatus from (contentId: Content) to (contentId: ContentId)
- 642 Remove CalculateNumTrianglesInMeshSync
- 642 Remove CalculateNumTrianglesInMesh
- 640 Add GetDependencyContentIds
- 573 Change ReturnType of UnregisterEncryptedAsset from void to null
- 573 Change ReturnType of UnregisterDefaultEncryptionKey from void to null
- 573 Change ReturnType of SetBaseUrl from void to null
- 573 Change ReturnType of RegisterSessionEncryptedAsset from void to null
- 573 Change ReturnType of RegisterEncryptedAsset from void to null
- 573 Change ReturnType of RegisterDefaultSessionKey from void to null
- 573 Change ReturnType of RegisterDefaultEncryptionKey from void to null
- 573 Change ReturnType of PreloadAsync from void to null
- 573 Change ReturnType of Preload from void to null
- 564 Add GetAssetFetchStatusChangedSignal
- 564 Add GetAssetFetchStatus
- 553 Change PreferredDescriptor of Preload from to PreloadAsync
- 553 Change Default of RequestQueueSize from to
- 553 Change Default of BaseUrl from to
- 506 Add GetDetailedFailedRequests
- 486 Change ThreadSafety of RequestQueueSize from ReadOnly to ReadSafe
- 486 Change ThreadSafety of BaseUrl from ReadOnly to ReadSafe
- 462 Change ThreadSafety of AssetFetchFailed from to Unsafe
- 462 Change ThreadSafety of UnregisterEncryptedAsset from to Unsafe
- 462 Change ThreadSafety of UnregisterDefaultEncryptionKey from to Unsafe
- 462 Change ThreadSafety of SetBaseUrl from to Unsafe
- 462 Change ThreadSafety of RegisterSessionEncryptedAsset from to Unsafe
- 462 Change ThreadSafety of RegisterEncryptedAsset from to Unsafe
- 462 Change ThreadSafety of RegisterDefaultSessionKey from to Unsafe
- 462 Change ThreadSafety of RegisterDefaultEncryptionKey from to Unsafe
- 462 Change ThreadSafety of PreloadAsync from to Unsafe
- 462 Change ThreadSafety of Preload from to Unsafe
- 462 Change ThreadSafety of ListEncryptedAssets from to Unsafe
- 462 Change ThreadSafety of GetFailedRequests from to Unsafe
- 462 Change ThreadSafety of CalculateNumTrianglesInMeshSync from to Unsafe
- 462 Change ThreadSafety of CalculateNumTrianglesInMesh from to Unsafe
- 462 Change ThreadSafety of RequestQueueSize from to ReadOnly
- 462 Change ThreadSafety of BaseUrl from to ReadOnly
- 454 Add AssetFetchFailed
- 452 Remove AssetFetchFailed
- 453 Add AssetFetchFailed
- 452 Add RegisterSessionEncryptedAsset
- 452 Add RegisterDefaultSessionKey
- 446 Add UnregisterEncryptedAsset
- 446 Add UnregisterDefaultEncryptionKey
- 446 Add RegisterEncryptedAsset
- 446 Add RegisterDefaultEncryptionKey
- 446 Add ListEncryptedAssets
- 403 Add CalculateNumTrianglesInMeshSync
- 398 Add GetFailedRequests
- 396 Add CalculateNumTrianglesInMesh
- 386 Change Parameters of PreloadAsync from (contentIdList: Array) to (contentIdList: Array, callbackFunction: Function = nil)
- 311 Remove SetThreadPool
- 311 Remove SetCacheSize
- 311 Remove SetAssetUrl
- 311 Remove GetFailedUrls
- 307 Change Tags of Preload from [] to [Deprecated]
- 277 Add GetFailedUrls
- 200 Add PreloadAsync
- 71 Change Parameters of Preload from (ContentId: Content) to (contentId: Content)
- 66 Remove GetRequestedUrls
- 66 Remove GetRequestQueue
- 47 Add SetThreadPool
- 47 Add SetCacheSize
- 47 Add SetBaseUrl
- 47 Add SetAssetUrl
- 47 Add Preload
- 47 Add GetRequestedUrls
- 47 Add GetRequestQueue
- 47 Add RequestQueueSize
- 47 Add BaseUrl
- 47 Add ContentProvider
Members 17
AssetFetchFailed
Parameters (1) | |
---|---|
assetId | ContentId |
Thread safety | Unsafe |
---|
History 5
- 645 Change Parameters of AssetFetchFailed from (assetId: Content) to (assetId: ContentId)
- 462 Change ThreadSafety of AssetFetchFailed from to Unsafe
- 454 Add AssetFetchFailed
- 452 Remove AssetFetchFailed
- 453 Add AssetFetchFailed
BaseUrl
Type | Default | |
---|---|---|
string |
Used by the ContentProvider to download assets from the Roblox website.
This URL points to a Roblox hosted website from which assets are downloaded and is pulled from the AppSettings.xml file, located in the version-hash folder.
It is possible to overwrite this property using the ContentProvider:SetBaseUrl() function in the command bar; however, this is not recommended and may cause asset loading issues.
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false/true |
GetAssetFetchStatus
Parameters (1) | ||
---|---|---|
contentId | ContentId | |
Returns (1) | ||
AssetFetchStatus |
Gets the current AssetFetchStatus of the contentId
provided. Use
GetAssetFetchStatusChangedSignal()
to listen for changes to this value.
Thread safety | Unsafe |
---|
History 2
- 645 Change Parameters of GetAssetFetchStatus from (contentId: Content) to (contentId: ContentId)
- 564 Add GetAssetFetchStatus
GetAssetFetchStatusChangedSignal
Parameters (1) | ||
---|---|---|
contentId | ContentId | |
Returns (1) | ||
RBXScriptSignal |
A signal that fires when the AssetFetchStatus of the provided content changes. Connect to this signal by using a callback with one argument of type AssetFetchStatus. This is particularly useful for assets that might update themselves automatically like the thumbnail of a user when they change clothes.
Thread safety | Unsafe |
---|
History 2
- 645 Change Parameters of GetAssetFetchStatusChangedSignal from (contentId: Content) to (contentId: ContentId)
- 564 Add GetAssetFetchStatusChangedSignal
GetDependencyContentIds
Parameters (1) | ||
---|---|---|
root | Instance | |
Returns (1) | ||
Array |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 1
GetFailedRequests
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 2
- 462 Change ThreadSafety of GetFailedRequests from to Unsafe
- 398 Add GetFailedRequests
ListEncryptedAssets
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
Thread safety | Unsafe |
---|
History 2
- 462 Change ThreadSafety of ListEncryptedAssets from to Unsafe
- 446 Add ListEncryptedAssets
Preload
Parameters (1) | ||
---|---|---|
contentId | ContentId | |
Returns (1) | ||
null |
Usually, content is loaded only when it starts being used. That explains
why it often takes a moment for an image to appear in a
GUI, or a Mesh|mesh
to appear in a
part, or why a sound doesn't play for the
first time. All because the asset has not yet finished loading. Preload is
used to load this content beforehand, so that it works instantly.
Thread safety | Unsafe |
---|
History 7
- 645 Change Parameters of Preload from (contentId: Content) to (contentId: ContentId)
- 573 Change ReturnType of Preload from void to null
- 553 Change PreferredDescriptor of Preload from to PreloadAsync
- 462 Change ThreadSafety of Preload from to Unsafe
- 307 Change Tags of Preload from [] to [Deprecated]
- 71 Change Parameters of Preload from (ContentId: Content) to (contentId: Content)
- 47 Add Preload
PreloadAsync
Parameters (2) | Default | |
---|---|---|
contentIdList | Array | |
callbackFunction | Function | nil |
Returns (1) | ||
null |
Yields until all of the assets associated with the given Instances have loaded. This can be used to pause a script and not use content until it is certain that the content has been loaded into the experience.
When called, the engine identifies links to content for each item in the list. For any of the Instances which have properties that define links to content, such as a Decal or a Sound, the engine attempts to load these assets from Roblox. For each requested asset, the callback function runs, indicating the asset's final AssetFetchStatus.
This method can also take in a list of content ID strings, however these strings must correspond to image assets. Attempting to load non-image assets through the use of their content ID strings will result in failure.
If any of the assets fail to load, an error message appears in the output. The method itself will not error and it will continue executing until it has processed each requested instance or asset ID.
Thread safety | Unsafe |
---|
History 4
- 573 Change ReturnType of PreloadAsync from void to null
- 462 Change ThreadSafety of PreloadAsync from to Unsafe
- 386 Change Parameters of PreloadAsync from (contentIdList: Array) to (contentIdList: Array, callbackFunction: Function = nil)
- 200 Add PreloadAsync
RegisterDefaultEncryptionKey
Parameters (1) | ||
---|---|---|
encryptionKey | string | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of RegisterDefaultEncryptionKey from void to null
- 462 Change ThreadSafety of RegisterDefaultEncryptionKey from to Unsafe
- 446 Add RegisterDefaultEncryptionKey
RegisterDefaultSessionKey
Parameters (1) | ||
---|---|---|
sessionKey | string | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of RegisterDefaultSessionKey from void to null
- 462 Change ThreadSafety of RegisterDefaultSessionKey from to Unsafe
- 452 Add RegisterDefaultSessionKey
RegisterEncryptedAsset
Parameters (2) | ||
---|---|---|
assetId | ContentId | |
encryptionKey | string | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 4
- 645 Change Parameters of RegisterEncryptedAsset from (assetId: Content, encryptionKey: string) to (assetId: ContentId, encryptionKey: string)
- 573 Change ReturnType of RegisterEncryptedAsset from void to null
- 462 Change ThreadSafety of RegisterEncryptedAsset from to Unsafe
- 446 Add RegisterEncryptedAsset
RegisterSessionEncryptedAsset
Parameters (2) | ||
---|---|---|
contentId | ContentId | |
sessionKey | string | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 4
- 645 Change Parameters of RegisterSessionEncryptedAsset from (contentId: Content, sessionKey: string) to (contentId: ContentId, sessionKey: string)
- 573 Change ReturnType of RegisterSessionEncryptedAsset from void to null
- 462 Change ThreadSafety of RegisterSessionEncryptedAsset from to Unsafe
- 452 Add RegisterSessionEncryptedAsset
RequestQueueSize
Type | Default | |
---|---|---|
int |
Gives the number of items in the ContentProvider request queue that need 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).
Thread safety | ReadSafe |
---|---|
Category | Data |
Loaded/Saved | false/true |
History 4
- 553 Change Default of RequestQueueSize from to
- 486 Change ThreadSafety of RequestQueueSize from ReadOnly to ReadSafe
- 462 Change ThreadSafety of RequestQueueSize from to ReadOnly
- 47 Add RequestQueueSize
SetBaseUrl
Parameters (1) | ||
---|---|---|
url | string | |
Returns (1) | ||
null |
Security | LocalUserSecurity |
---|---|
Thread safety | Unsafe |
History 3
- 573 Change ReturnType of SetBaseUrl from void to null
- 462 Change ThreadSafety of SetBaseUrl from to Unsafe
- 47 Add SetBaseUrl
UnregisterDefaultEncryptionKey
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 3
- 573 Change ReturnType of UnregisterDefaultEncryptionKey from void to null
- 462 Change ThreadSafety of UnregisterDefaultEncryptionKey from to Unsafe
- 446 Add UnregisterDefaultEncryptionKey
UnregisterEncryptedAsset
Parameters (1) | ||
---|---|---|
assetId | ContentId | |
Returns (1) | ||
null |
Thread safety | Unsafe |
---|
History 4
- 645 Change Parameters of UnregisterEncryptedAsset from (assetId: Content) to (assetId: ContentId)
- 573 Change ReturnType of UnregisterEncryptedAsset from void to null
- 462 Change ThreadSafety of UnregisterEncryptedAsset from to Unsafe
- 446 Add UnregisterEncryptedAsset
Removed members 9
CalculateNumTrianglesInMesh
Parameters (1) | ||
---|---|---|
meshId | string | |
Returns (1) | ||
int |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 3
- 642 Remove CalculateNumTrianglesInMesh
- 462 Change ThreadSafety of CalculateNumTrianglesInMesh from to Unsafe
- 396 Add CalculateNumTrianglesInMesh
CalculateNumTrianglesInMeshSync
Parameters (1) | ||
---|---|---|
meshId | string | |
Returns (1) | ||
int |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 3
- 642 Remove CalculateNumTrianglesInMeshSync
- 462 Change ThreadSafety of CalculateNumTrianglesInMeshSync from to Unsafe
- 403 Add CalculateNumTrianglesInMeshSync
GetDetailedFailedRequests
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 2
GetFailedUrls
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
Security | LocalUserSecurity |
---|
History 2
- 311 Remove GetFailedUrls
- 277 Add GetFailedUrls
GetRequestQueue
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
Security | LocalUserSecurity |
---|
History 2
- 66 Remove GetRequestQueue
- 47 Add GetRequestQueue
GetRequestedUrls
Parameters (0) | ||
---|---|---|
No parameters. | ||
Returns (1) | ||
Array |
Security | LocalUserSecurity |
---|
History 2
- 66 Remove GetRequestedUrls
- 47 Add GetRequestedUrls
SetAssetUrl
Parameters (1) | ||
---|---|---|
url | string | |
Returns (1) | ||
void |
Security | LocalUserSecurity |
---|
History 2
- 311 Remove SetAssetUrl
- 47 Add SetAssetUrl
SetCacheSize
Parameters (1) | ||
---|---|---|
count | int | |
Returns (1) | ||
void |
Security | LocalUserSecurity |
---|
History 2
- 311 Remove SetCacheSize
- 47 Add SetCacheSize
SetThreadPool
Parameters (1) | ||
---|---|---|
count | int | |
Returns (1) | ||
void |
Security | LocalUserSecurity |
---|
History 2
- 311 Remove SetThreadPool
- 47 Add SetThreadPool