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
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
- UI element scale and position are wrong in project build when DRS is changed with HDR and Software Dynamic Resolution enabled
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.