stride3d / stride3d/stride

Game Studio scene error memory leak on closing sub-window

Open
#615 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-GameStudio bug
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:

  1. Create a new StartupScript asset called FaultScript (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(); }
}
  1. Create an entity (if one does not exist), then attach the script to it.
  2. Uncomment the exception line, save the script, then reload when the editor asks to reload.
  3. 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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.