godotengine / godotengine/godot

C# scenes with `NodePath`s randomly fail to load correctly (instead replaced with null)

Open
#93,083 1 comment 3 reactions 0 assignees View on GitHub
bug needs testing topic:core topic:dotnet
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.2.2.stable.mono, also reproducible in 4.3
- Not reproducible in 3.5

### System information

Most likely Windows 10 with Vulkan Forward+ renderer ~~and a cyrillic locale (only players have seen this issue)~~there's been enough reports now that I don't think this part is relevant

### Issue description

It seems that Godot 4 randomly fails to load `NodePath` export variables for C# scripts when instantiating scenes. The scenes in question load fine thousands of times, but very rarely it seems like they don't load correctly after playing some time.

I know this is basically probably unsolvable but I want to report this problem anyway as I've received multiple reports from players of my game that they have gotten this issue. I've opened a meta tracking issue in my repo about this: https://github.com/Revolutionary-Games/Thrive/issues/5209

There's a chance that this is not in the end an engine issue, but all the info so far I have about this is that for some reason an instantiated C# class just has some export properties set to null when loading. Way earlier in the process from porting from Godot 3 to 4 I noticed 2 scenes that were much much more likely to have this issue present in them and I switched them to using direct node references. That seems to be a working workaround for this as I've not received any reports where those two scenes. So that leads me to believe there is some rare bug in the engine related to `NodePath` variable handling in scene instantiation.

I have not switched everything over to using direct node references as it would be a lot of work to convert over hundreds of scenes. Once [that is eventually done](https://github.com/Revolutionary-Games/Thrive/issues/4940), this issue should no longer really be relevant to Thrive anymore.

### Steps to reproduce

- Have a scene with a C# script attached to the root node
- Add an `[Export]` variable of `NodePath` type
- Add a valid path to that variable
- Load the scene thousands of times and hope to somehow trigger the issue... (I know this step is not really feasible, also this is the reason why I haven't managed to narrow down this issue at all)

### Minimal reproduction project (MRP)

I think it speaks to the rarity of the issue that the Godot 4 version of Thrive has been downloaded thousands of times but I have received less than 5 reports of this problem.

Update: we regularly receive bug reports about this after each new game version release. It seems that it takes hours of gameplay in a single session to trigger this bug. For example the latest bug report about this to us is here: https://community.revolutionarygamesstudio.com/t/0-8-1-1-after-game-loads-microbes-are-not-visible-on-screen-and-i-cant-move-or-click-any-buttons/8298

So even if I tried for hours it would be unlikely I would be able to make a MRP.

Version of Thrive that definitely has this issue in it is: https://github.com/Revolutionary-Games/Thrive/tree/v0.6.6 (I added some workarounds in later patches so this issue may no longer be able to be triggered as I switched a few more scenes to use node references instead of paths).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.