Zinnia.Unity: ValueExtractor has some edge cases breaking IL2CPP builds
Environment
- Code source: Package manager
- Code version: “io.extendreality.zinnia.unity”: “1.16.0”
- Platform version: Unity 2019.2.21f1
- 3rd party dependencies: None
Steps to reproduce
- Create a new project,
- Add a script to the main scene that does the following
using UnityEngine;
using Zinnia.Data.Operation.Extraction;
public class Example : MonoBehaviour
{
void Start()
{
// We force the type to appear
Debug.Log(typeof(SurfaceDataCollisionPointExtractor));
}
}
- Save the scene
- Set scripting backend to IL2CPP and build
Expected behavior
Should build.
Current behavior
IL2CPP compilation error.
It seems that ValueExtractor
has some edge cases that breaks the AOT scripting restrictions causing the build to fail.
I tried setting Stripping level to high and it still won’t build.
Also, the class that I used to reproduce the error is SurfaceDataCollisionPointExtractor
, but some other classes, like SurfaceDataCollisionDataExtractor
don’t cause this problem, so it seems to be a problem with the type RaycastHit
.
Part of the log which seems useful says:
error C2440: ‘type cast’: cannot convert from ‘int’ to RaycastHit_t19695F18F9265FE5425062BBA6A4D330480538C3’
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 30 (18 by maintainers)
I opened a case with Unity and just got the following response:
—-
It looks like there is invalid IL code in Zinnia.Runtime.dll. The problem happens in the Zinnia.Data.Operation.Extraction.ValueExtractor<TResultElement,TSourceElement,TEvent,TEventElement>.ClearSource method. In this case, TSourceElement is UnityEngine.RaycastHit. The C# code for ClearSource (from ILSpy) is:
[CompilerGenerated] public void ClearSource() { Source = (TSourceElement)null; }
Since UnityEngine.RaycastHit is a struct, it is not nullable, and therefore cannot be set to a value of null.
I don’t believe this is something we can correct on the Unity side.
I just tried with the new version and couldn’t replicate the issue anymore. Thank you very much for the fix!
@bddckr ok cool, as long as it’s expected. I’ll raise a PR with this fix in
That’s expected and on purpose: https://github.com/ExtendRealityLtd/Malimbe/blob/c2ea3fe3e304f6bc142bb34503886f6909a6639e/Sources/MemberClearanceMethod.Fody/ModuleWeaver.cs#L80-L83
This allows one to add additional logic to the method, while keeping the auto-injected logic from Malimbe.
So yeah, you need to remove the attribute if you want to replace Malimbe’s logic.
That seems to do the trick @thestonefox 😃 Build was successful
Edit: For Android and Windows Standalone
Can you try in the
ValueExtractor.cs
file on line23
removing theCleared
flagso it just reads:
(this is on default Zinnia 1.17.0 you don’t need the extra suggested changes above)
This PR has now been merged, so the issue in Zinnia is fixed.
The Tilia repos will be updated to the latest version of Zinnia.
Please note that VRTK.Prefabs will not receive any Zinnia updates as there may be compatibility issues so you’ll have to apply this fix manually.