stride3d / stride3d/stride

Script System throws an exception while handling a different exception when closing a window using the windows X button

Open
#2,757 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
7.8k
Forks
1.2k
Avg merge
2d 12h
Merged PRs (30d)
54

Description

Release Type: Official Release

Version: 4.2.0.2381

Platform(s): Windows, possibly others

Describe the bug
When closing a game's window with the X button, if there is an exception in the Cancel in one of the components, the script systems throws it's own NullReferenceException for the Scheduler (ScriptSystem.cs line:252) while trying to handle the previous one. This doesn't happen when you use Enviroment.Exit, as it doesn't call the Cancel methods.

This bug doesn't break anything, but it just makes working with the engine extremely annoying as it keeps focusing onto the ScriptSystem file in visual studio and at least for now, the debugger seems to be ignoring any setting to ignore that file.

To Reproduce
Steps to reproduce the behavior:

  1. Create a StartupScript that throws an exception in the Cancel method.
  2. Run the game while debugging
  3. Close the window using the Windows X button.

Expected behavior
The cancel methods aren't called when closing (I understand that doing this is a cleaner solution, but also more prone to throwing exceptions that don't matter), the script system ignores other exceptions when the scheduler is null or the scheduler doesn't get set to null.

Screenshots
Image

Log and callstacks
scriptsystemexception.txt

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 ScriptSystem.cs around line 252 and reproduce the issue with a StartupScript that throws from Cancel while closing the window with the Windows X button. Compare this with Environment.Exit and the supplied log; done means the original cancellation exception no longer causes a Scheduler NullReferenceException.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.