Skip to content

Conversation

@lucaheft
Copy link
Contributor

Description

This PR removes the implicit loading of assets with preload=true, when they are added to the asset registry.

Fixes #3107

I hope this gets some traction here, this is currently blocking our custom loading solution when using multiple scenes https://forum.playcanvas.com/t/assetregistry-not-available-in-custom-loading-script-v2/40918

Checklist

  • I have read the contributing guidelines
  • My code follows the project's coding standards
  • This PR focuses on a single change

@mvaligursky
Copy link
Contributor

Can this be closed now due to #8177 ?

@lucaheft
Copy link
Contributor Author

lucaheft commented Nov 25, 2025

This PR is independent from #8177.

This PR moves loading of preloaded assets from AssetRegistry.add to AppBase.preload.

The other PR implements AssetListLoader in AppBase.preload to load preloaded assets instead of using the current custom solution.

@Maksims
Copy link
Collaborator

Maksims commented Nov 26, 2025

This looks like a breaking change, as it will change the logic of other systems?
Has this been tested and verified with various cases where people might expect for assets to be loaded. And if the behavior will change with this PR - then it cannot be pushed as is.
If that is the case, then there should be some flag, that by default preserves current behavior, but allows also to disable auto-loading if some flag is switched off.

@lucaheft
Copy link
Contributor Author

Agreed that this is indeed changing behaviour.

If a asset with preload set to true is added at runtime, you now additionally need to call app.assets.load(asset)
Previously app.assets.add(asset) would have been enough.

However the current behaviour is not in line with the docs for Asset.preload:

Sets whether to preload an asset. If true, the asset will be loaded during the preload phase of application set up.

@Maksims
Copy link
Collaborator

Maksims commented Nov 26, 2025

So based on that, we cannot risk breaking people's app logic, as behavior will change. And it should be "opt-in" feature - via the flag.

@lucaheft
Copy link
Contributor Author

I'd still advocate to change this.

Is it breaking behaviour if the behaviour based on the docs was never intended to work this way? I'd say this is a bug and even if someone relies on this behaviour they didn't implement it correctly in the first place.

I think the impact on the user base will be minimal.

@mvaligursky
Copy link
Contributor

We can just as well say the issue is in the docs and we fix the docs.
Many things are complicated to change due to this, and we always try to find some solution to keep existing users happy, at least in common cases.

@lucaheft
Copy link
Contributor Author

If we dont want to change this behaviour it should definitely be documented.

Unfortunetly this wont solve my problem of customizing loading behaviour, before app.assets.add is called, when exporting from the editor.
However this can also be solved by adding an event in AppBase.init. Are you open to this?

@mvaligursky
Copy link
Contributor

However this can also be solved by adding an event in AppBase.init. Are you open to this?

Totally, a useful generic event at the right place is a good option for many use cases.

@lucaheft
Copy link
Contributor Author

Closing in favour of #8189

@lucaheft lucaheft closed this Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Should AssetRegistery#add also load assets if marked as preload?

3 participants