engine: Material assets/resources don't load again after being unloaded since version 1.48.0+

Project: https://playcanvas.com/project/849163/overview/error-when-adding-template

Steps to repro:

  1. Launch Scene ‘Start’
  2. Press Space to load the Untitled scene with the Ambulance
  3. Press Space again to load the scene ‘Start’ with the cube
  4. Press 1 to unload assets with the tag ‘Maze1’
  5. Press Space to load the Untitled scene with the Ambulance
  6. Crash with the following callstack
playcanvas.dbg.js?version=1.49.1:20557 Uncaught TypeError: Cannot read properties of null (reading 'alphaToCoverage')
    at MeshInstance.updateKey (playcanvas.dbg.js?version=1.49.1:20557)
    at MeshInstance.set (playcanvas.dbg.js?version=1.49.1:20828)
    at new MeshInstance (playcanvas.dbg.js?version=1.49.1:20465)
    at Model.clone (playcanvas.dbg.js?version=1.49.1:28839)
    at ModelComponent._onModelAssetLoad (playcanvas.dbg.js?version=1.49.1:59592)
    at ModelComponent._bindModelAsset (playcanvas.dbg.js?version=1.49.1:59569)
    at ModelComponent.set (playcanvas.dbg.js?version=1.49.1:59713)
    at ModelComponentSystem.initializeComponentData (playcanvas.dbg.js?version=1.49.1:60091)
    at ModelComponentSystem.addComponent (playcanvas.dbg.js?version=1.49.1:43636)
    at SceneParser._openComponentData (playcanvas.dbg.js?version=1.49.1:35086)

On engine version 1.47.2, the scene loads fine both times

https://launch.playcanvas.com/1268937?debug=true&use_local_engine=https://code.playcanvas.com/playcanvas-1.47.2.js

Breaking commit since 1.47.2 is https://github.com/playcanvas/engine/pull/3557

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (19 by maintainers)

Most upvoted comments

My only concern around any of this is… 🌴 shaking.

Yep I considered this. But storing a pointer on an object does not require the import of the class, so this does not change the 🌴 shakeability.

| We only have one scene per application now at the moment right?

Engine has one. Editor creates scenes as it generates thumbnails. Users can create scenes as well.

It’s not about exact number, it’s about where things correctly belong on the architecture level. And it allows me to solve this bug, which is a side benefit.