Search Issue Tracker
Won't Fix
Won't Fix in 1.3.X, 2.0.X
Votes
0
Found in [Package]
1.3.0
2.0.1-pre.18
2.0.1
Issue ID
DSTR-558
Regression
No
Editor hangs when using Assert.ThrowsAsync in a test
How to reproduce:
1. Open the attached “ThrowsAsyncBug” project
2. In the main menu bar, select “Window” → “General” → “Test Runner”
3. Run the “ThrowsAsync_WhenCallingAsyncTask_LocksUnityAsync” test
4. Observe the progress bar
Expected result: The progress bar finishes loading without problems
Actual result: The progress bar never finishes, putting the entire Editor in deadlock
Reproducible with: 2.0.1-exp.1 (2021.3.6f1), 2.0.1-pre.12 (2022.1.10f1), 2.0.1-pre.18 (2022.2.0b2)
Couldn’t test with: 1.1.33 (2020.3.37f1), 2.0.1-pre.18 (2023.1.0a4) (Compilation errors)
Reproducible on: Windows 10
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Terrain Masks do not ignore the mipmap limit
- "Build And Run" the project for Web is allowed even though the directory for the non-default browser is not selected
- [Linux] D-Pad is either not working or sometimes working when UI->Navigation is set to "Pass Through" in Input Actions
- [FrameDebugger] Missing Help button that should lead to the documentation page
- [Android] [UIToolkit] FPS does not reach 30 when the most basic UI Document is displayed in the application
Resolution Note:
There are no fixes planned for this Bug
Resolution Note (1.3.X):
The reason why the editor freezes is that Assert.ThrowsAync blocks the main editor thread. In general we provide IEnumerator alternatives to such calls, which will work instead, but we do not yet have one for ThrowsAsync. Until we add that in a minor release in the future, you are able to work around the issue by adding similar code. The following snippet will use an UnityTest to check on every frame update if the async method is doen running and once it is done, it will evaluate the exception.
[UnityTest]
public IEnumerator UnityThrowsAsync_WhenCallingAsyncTask_Solution()
{
yield return AssertThrowAsync<Exception>(ThrowException);
}
private IEnumerator AssertThrowAsync<T>(AsyncTestDelegate code) where T : Exception
{
var task = code();
while (!task.IsCompleted)
{
yield return null;
}
Assert.That<Exception>(task.Exception != null && task.Exception.InnerExceptions.Count == 1 ? task.Exception.InnerException : task.Exception, new ExceptionTypeConstraint(typeof(T)));
}
Resolution Note (2.0.X):
Won't do any 2.0 fixes, 2.0 is never going to be released