Search Issue Tracker
By Design
By Design in 2022.1.X
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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
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.
Resolution Note (2022.1.X):
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.