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
- Crash on SpriteAtlas::PopulatePackedTexturesAndRenderData when changing Import Settings on a Sprite that has been added to a Sprite Atlas while in PlayMode
- Empty lists can be applied in Additional Compiler Argument list in Project Settings
- [Vulkan][OpenXR] SRP Foveation Regions Not Centered when eye-tracking is not used
- Long Color Library name overflows outside input field bounds
- Shader Graph validation and Metal threadgroup memory warnings thrown when installing HDRP package in Universal 3D Template
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