Search Issue Tracker
Fixed in 2020.3.X, 2021.1.X
[IL2CPP] Incorrect results when calling a method from outside Class in a Struct
How to reproduce:
1. Open the attached "MutableStructRepro.zip" Project
2. Make sure the "IL2CPP" is selected in the Project Settings
3. Build and Run the Project
4. Press the only button in the scene
Expected Behavior: Label shows "567" value
Actual Behavior: Label shows "456" value
Reproducible with: 2018.4.24f1, 2019.4.2f1, 2020.1.0b14, 2020.2.0a14
Note: The code is in "NewBahaviorScript.cs". It seems that the code in the 88th line is not executed.
Sep 27, 2020 16:01
Currently, UniTask needs a workaround for this problem.
This is not desirable as it is accompanied by an extra steps.
Sep 26, 2020 09:06
A fix for this would be very helpful for async method builders. As it is, I have to `#if ENABLE_IL2CPP` to rewrite my entire builders for less efficient versions, just so it will work.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- Containers' height doesn't expand when text wraps
- Variable is set to a different value from the selected enum value in the Editor dropdown
- TreeView Child display toggle styling becomes reversed when clicking and dragging it
- Null is returned when using FocusOutEvent.relatedTarget
- Unity_BaseInstanceID is always zero when rendering multiple meshes and instancing with the same buffer
Resolution Note (2020.2.X):
Thank you for your bug report. We have reproduced your issue and have confirmed that in the conditions:
1. A generic class A<T>
2. A generic mutable struct B<T>
3. A<T> calls a method on B<T>
4. The call to B<T> makes a call to code that accesses the B<T> instance from its original location.
5. That call makes a update a property to B<T>
The update make step 5 are lost.
Unfortunately correcting this issue will take some time to fix as it will require changes that will affect all generic method calls. This has been added to our internal issues list and will do plan on fixing it, but I cannot give you a timeframe for that fix will be available.
Please let us know if you need any assistance with a work around. But changing any of the conditions above would do so. For example if the mutable struct B<T> is not generic then the issue does not occur or if any changes to B<T> in step 4 are made directly using the this pointer then the issue will not occur.
Resolution Note (fix version 2021.1):
Fixed in 2021.1.24f1