playcanvas / editor

Issue tracker for the PlayCanvas Editor
https://playcanvas.com/
160 stars 28 forks source link

Unstable Scripts Loading Order #1185

Closed marklundin closed 1 month ago

marklundin commented 3 months ago

This was originally raised on the forum. I've been able to test and replicate.

Issue

When an script asset property is updated in the editor, it changes the number and order of the scripts in the Scripts Loading Order panel.

repro

  1. Open this project, open Scripts Loading Order panel in settings
  2. Note the total number of scripts loaded (should be around 276)
  3. In the SCRIPTS dir in the Asset Registry, select any single script instance, and toggle one of it's properties eg 'preload', or 'exclude.
  4. Go back to the Scripts Loading Order in the settings panel, note that the total number of scripts has changed, and the order of of scripts is different

See this vid for additional repro https://www.loom.com/share/60d3b2f5eb2047d8abc1f4559f76c7bc?sid=a8270a4b-0955-40bd-8d8d-ce50aeba6413

Notes

Additionally, the scripts data comes from window.config.project.settings.scripts, this starts as an array, however, when a property of a single script asset is updated, it's mutated to become an Object<number, string>, but the keys and values are now incorrect.

Also, the first few values seem to be correct, however it eventually drifts out of sync.

gbelintani commented 2 months ago

I'm not sure if this can help, but I had a similar problem. I had a total of 202 scripts, due to a test we were doing, through the editor API we set everything in the project to preload false, and then set all scripts to preload true, but only 189 were added to the script order window. This resulted in a scene that when published with concatenate script setting on, the scene was all broken up, but worked fine with the same setting set to off.

We got the missing scripts in the console window as being not found when we ran the project, toggling the preload to false, then true to each of them individually readded to the script order window again and everything runs fine now.

marklundin commented 2 months ago

Thanks for the heads up @gbelintani, we've figured out what the issue is now. Just working on a fix

marklundin commented 1 month ago

We now have a fix for this! 🚀 😅