feat: enable asset load retries by default#8744
Merged
Merged
Conversation
Previously the engine only retried failed asset loads when the integrator explicitly opted in via the maxAssetRetries application property. Any transient network glitch would immediately surface as a permanent load failure. AppBase now calls loader.enableRetry(5) after registering resource handlers, so every app gets 5 retries with exponential backoff out of the box. The maxAssetRetries application property still overrides the default when set to a positive number. Also promotes ResourceLoader.enableRetry / disableRetry to public API (removing @ignore) so engine-only users can configure retries without going through the scene-settings path.
Contributor
There was a problem hiding this comment.
Pull request overview
Enables asset load retries by default to improve resilience against transient network failures, and exposes retry controls (enableRetry / disableRetry) as public API on ResourceLoader.
Changes:
- Default asset load retries are enabled for all new applications (configured in
AppBase). maxAssetRetriesapplication property continues to override retry behavior when set.ResourceLoader.enableRetry()/disableRetry()are promoted to public API by removing@ignoreand updating JSDoc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/framework/handlers/loader.js | Updates JSDoc and exposes retry configuration methods as public API. |
| src/framework/app-base.js | Enables retries by default during app init and keeps maxAssetRetries override logic. |
Comments suppressed due to low confidence (3)
src/framework/app-base.js:806
- With retries now enabled by default in the constructor, this override logic no longer allows configs to explicitly disable retries via
maxAssetRetries: 0. IfmaxAssetRetriesis present and set to 0, the app will still retry 5 times. Consider treating any numeric value as an override (e.g., callenableRetry(props.maxAssetRetries)when it’s a number, or explicitly calldisableRetry()when it’s 0) to preserve an opt-out path via application properties.
// configure retrying assets - overrides the default set in the constructor
if (typeof props.maxAssetRetries === 'number' && props.maxAssetRetries > 0) {
this.loader.enableRetry(props.maxAssetRetries);
}
src/framework/handlers/loader.js:344
- Now that
enableRetryis part of the public API, it would help to normalizemaxRetriesto an integer (e.g., viaMath.floor) after clamping. Passing a non-integer today results in a non-obvious number of attempts becauseHttpcompares an integer retry counter against this value.
enableRetry(maxRetries = 5) {
maxRetries = Math.max(0, maxRetries) || 0;
src/framework/app-base.js:633
- This changes the default network behavior for all apps (retries enabled by default). Consider adding a unit test that asserts a newly constructed
Application/AppBasehas non-zeromaxRetrieson its handlers, and that_parseApplicationPropertiescorrectly overrides (including disabling when configured).
// default to retrying failed asset loads to make apps more resilient to transient network
// errors
this.loader.enableRetry(5);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // default to retrying failed asset loads to make apps more resilient to transient network | ||
| // errors | ||
| this.loader.enableRetry(5); |
mvaligursky
added a commit
to playcanvas/developer-site
that referenced
this pull request
May 18, 2026
Documents the engine's asset load retry behaviour, which now defaults to 5 retries with exponential backoff (playcanvas/engine#8744), and the newly-public ResourceLoader.enableRetry / disableRetry API. Adds a new "Configuring Retries" section to the Loading and Unloading page covering the default, global override, per-handler override and a cross-link to the Editor Network Settings page. Mirrors the change to the Japanese translation. Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
mvaligursky
added a commit
that referenced
this pull request
May 18, 2026
…#8745) Small follow-up to #8744 addressing review comments on ResourceLoader.enableRetry. - AppBase now calls this.loader.enableRetry() without arguments, so the default retry count (5) lives in a single place - the enableRetry signature - instead of being duplicated in AppBase. - enableRetry now floors maxRetries before clamping, so non-integer inputs produce a predictable number of attempts. Co-authored-by: Martin Valigursky <mvaligursky@snapchat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously the engine only retried failed asset loads when the integrator explicitly opted in via the
maxAssetRetriesapplication property. Any transient network glitch (slow CDN, mobile connectivity hiccup, server flap) would immediately surface as a permanent load failure.Changes:
AppBasenow callsthis.loader.enableRetry(5)immediately after the built-in resource handlers are registered, so every application gets 5 retries with exponential backoff out of the box.maxAssetRetriesapplication property continues to override the default when set to a positive number (Editor-driven scenes are unaffected).ResourceLoader.enableRetry()/ResourceLoader.disableRetry()to public API by removing their@ignoreJSDoc tags, giving engine-only users a clean way to configure retries without going through the scene-settings path. ThemaxRetriesparameter onenableRetryis also marked optional in the JSDoc.Behaviour change:
app.loader.disableRetry()after constructing the application, or pass a positive override via themaxAssetRetriesapplication property and a custom value.API Changes:
ResourceLoader.enableRetry(maxRetries?: number): voidis now public (was@ignore).ResourceLoader.disableRetry(): voidis now public (was@ignore).Example usage for engine-only projects: