Game Studio scene error memory leak on closing sub-window
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Release Type: Game Studio Official Release
Version: 3.1.01 and lower.
Platform(s): Windows
Describe the bug
In Game Studio, when a game scene has thrown an exception and shows the Before you resume, fix the failing asset (likely a graphics compositor or scene) error message, if you close the sub-window before fixing it, the game will not be destroyed, causing a memory leak.
To Reproduce
It is a bit difficult to get into a faulted state for testing as sometimes the editor will prefer a hard crash. The following steps should work:
- Create a new
StartupScriptasset calledFaultScript(keep the line commented out for the time being):
public class FaultScript : StartupScript
{
private int value;
//public int X { get => value; set => throw new Exception(); }
}
- Create an entity (if one does not exist), then attach the script to it.
- Uncomment the exception line, save the script, then reload when the editor asks to reload.
- The scene should now be in a faulted state, and closing the window will make it continue running in the background.
Comment out the exception line to be able to reload the scene again after reloading the project.
Expected behavior
Release the memory when the sub-window is closed regardless of error state.
Additional context
The exit code is passed through the ScriptSystem, however this is never run because the game checks a Faulted flag and exits early.
The update logic:
https://github.com/xenko3d/xenko/blob/951335d9d421889a7459130f3e68436c62d8a02c/sources/editor/Xenko.Editor/EditorGame/Game/EditorServiceGame.cs#L114-L118
The exit script/task that is meant to execute:
https://github.com/xenko3d/xenko/blob/3777bf3b05ad3d5ce06ffa87dce31cae03b8b174/sources/editor/Xenko.Assets.Presentation/AssetEditors/GameEditor/Services/EditorGameController.cs#L173-L180
You cannot force an update to try to make it run the exit script since it's executed last, and whatever threw the exception in the first place will probably throw again, preventing the exit script from ever running.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in sources/editor/Xenko.Editor/EditorGame/Game/EditorServiceGame.cs around the linked update logic, then read sources/editor/Xenko.Assets.Presentation/AssetEditors/GameEditor/Services/EditorGameController.cs around the exit script/task. Reproduce the faulted scene on Windows and trace the close path; done means closing the sub-window releases the game even when the scene is faulted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 43/100