Script System throws an exception while handling a different exception when closing a window using the windows X button
Nobody has claimed this yet.
- 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:
- Create a
StartupScriptthat throws an exception in theCancelmethod. - Run the game while debugging
- 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
Log and callstacks
scriptsystemexception.txt
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 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