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

  1. 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.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.