stride3d / stride3d/stride

Asset references not restored correctly on editor hot reload

Open
#806 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Asset area-GameStudio bug priority-Medium work-estimate-S
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 17h
Merged PRs (30d)
49

Description

Release Type: Github

Describe the bug
If Component A has a reference to an asset and Component B references Component A then the asset will be null when accessed in a processor for Component B after the editor has hot reloaded the assembly.

It seems that Component B references an old copy of Component A after reload, breaking in the debugger shows that the correct instance exists in the EntityManager but not in the component reference.

To Reproduce

  1. Create a component that references any asset, for example a Model.
  2. Create a second component that references the first
  3. Create a processor that loops through the second component types and uses the Model from the referenced component
  4. Add an entity with the first component type and set a reference to an asset
  5. Add an entity with the second component type and set a reference to the first component
  6. Re-save any script so that the editor hot reloads the assembly
  7. You will now get a null exception.

Additional context
A sample project that reproduces the issue can be found here: https://onedrive.live.com/?authkey=%21AE%2DOVsio9OJ13HE&id=AB3F11B2CDEC1EB4%21278400&cid=AB3F11B2CDEC1EB4

Adding a space to the script in the sample project and saving should cause the editor show a null exception after hot reload.

Hope I make sense, it's a bit difficult to describe :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked sample project and reproduce the failure by adding a space to a script and saving it to trigger editor hot reload. Trace how component references are restored during assembly reload, focusing on why Component B retains an old copy of Component A. Done means the asset remains accessible through the referenced component in the processor after reload, without the null exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.