Search Issue Tracker
By Design
Votes
0
Found in
2021.3.8f1
2022.1.13f1
Issue ID
UUM-11945
Regression
Yes
AsyncRoutine methods are called in different order in a specific project when Code Optimization mode is set to "Release Mode"
How to reproduce:
1. Open the attached “IN-13489” project
2. Enter the Play Mode in the “Assets → Empty” Scene
Expected result: The project continues its execution without “AssertionException” thrown
Actual result: “AssertionException: Received an event that was not expected” is thrown in the Console log with the project stuck in the menu
Reproducible with: 2021.3.8f1, 2022.1.13f1
Couldn’t test with: 2020.3.38f1, 2022.2.0b5, 2023.1.0a6 (project isn’t compatible)
Reproduced on: Windows 10
Couldn’t test on: macOS 12.3 (Intel) (user Packages throw errors)
Note: Following user’s information, the issue wasn’t present in 2020.3 LTS stream. However, with the provided project it isn’t possible to check
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
- "ShaderGraph" misses a space in the "Project Settings" section
- UI Builder inspector’s checkbox fields can be activated when clicking anywhere in the value field
- Unity icon is poorly visible in the "Build Profiles" window when "Dark" editor theme is selected
- UI Toolkit Transition Animation is ignored when background-size property has a starting value of 0
- Error "Assertion failed on expression: 'i->previewArtifactID == found->second.previewArtifactID'" is present when creating Render Texture
Resolution Note:
The behavior is actually as a result of a C# design choice detailed here: https://devblogs.microsoft.com/premier-developer/dissecting-the-async-methods-in-c/#async-machinery
The key part being: "The generated state machine is a class in debug mode and a struct in release mode. All the other types (except MoveNextRunner class) are defined in the BCL as structs."
In the case of this issue the customer's code was stashing a copy of the state machine and using it to call MoveNext. Which worked fine in Debug but in Release a copy was used instead of a reference resulting in inconsistent states when attempting to complete.