Search Issue Tracker
Won't Fix
Votes
0
Found in
2017.4.0f1
2017.4.14f1
Issue ID
1099266
Regression
No
[Mobile][IL2CPP] Devirtualization does not work for abstract classes
To reproduce:
1. Download attached project "Devirtualization_test.zip" and open in Unity
2. Open "SampleScene" scene
3. Set Scripting Backend to IL2CPP
4. Build for iOS or Android
5. Go to "Devirtualization_test/Temp/il2cppOutput/il2cppOutput" and open "Bulk_Assembly-CSharp_0.cpp"
Expected behaviour:
Call to cow.Speak() should read: `String_t* L_18 = Cow_Speak_m1607867742(L_16, /hidden argument/NULL);`
Actual behaviour:
Call to cow.Speak() reads: String_t* L_18 = VirtFuncInvoker0< String_t* >::Invoke(4 /* System.String Animal::Speak() */, L_17);
Notes:
- This issue does not reproduce on Windows Standalone and macOS Standalone
- This issue appears only on iOS and Android (IL2CPP)
- You can remove the "sealed" keyword from the Cow class in "FarmAbstract", repeat steps 1 - 5 and notice results are identical
- Could not check on Unity 2017.3 because project becomes corrupted
- Could not check on Unity 2019.1 because of this issue:
https://issuetracker.unity3d.com/issues/crash-on-mono-method-to-ir-when-trying-to-build-after-the-project-was-created-on-older-version-of-unity-net3-dot-5
Reproduced on Unity 2017.4.0f1, 2017.4.15f1, 2018.1.9f2, 2018.2.16f1 and 2018.3.0b10
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:
Unfortunately, the devirtualization is not working in this case because the IL bytecode emitted by the C# compiler does not allow IL2CPP to devirtualize the call. The declaring type of the method to call is Animal, not Cow, so IL2CPP cannot safely avoid the virtual call.