+1
Cannot Fix

User-defined conversion operators not in type options are not stubbed in AOT builds

Marko Kršul 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 1

I have problem with this part of graph, on iOS devices.
Everything works when playing in editor (0 errors or warnings).
Everything works when building for windows stand-alone.
When building for iOS, everything works except those 3 blocks.
I am kind of familiar on building bolt things on iOS with AOT Pre-build and stuff, and every other logic in the game works fine on a phone/ipad... and I have no clue how debug this.

update: when I remove those 3 blocks (velocity over lifetime), xcode doesn't report any error;


AotStubs.cs
xcode_debug.txt

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
Cannot Fix

Hi Marko! Sorry for the very late reply on this. I finally figured out the source of the issue.

In your graph, you are connecting the result of Get X, a float, to the input of Set X, which expects a MinMaxCurve. This is valid and Bolt lets you do it, because MinMaxCurve has a user-defined implicit conversion operator from float to MinMaxCurve. Bolt detects that from analyzing your C# codebase and converts it for you behind the scenes.

Now, the problem occurs when creating AOT stubs. Because MinMaxCurve is not included in your custom type options, Bolt does not include its conversion operators when generating AOT stubs. At runtime in your Android build then, because the conversion doesn't exist, Bolt removes the connection because it thinks it is incompatible.

The simple solution is to add MinMaxCurve to your custom types. Once this is done, re-run AOT pre-build, and everything should work fine.

The long-term fix on our end would be to make sure that Bolt notices this implicit conversion is used and generates the AOT stubs for it. It's a bit tricky because it requires port-level analysis of all graphs. Because it's such an edge case and it has an easy user workaround, and because that fix would become useless in Bolt 2's generated C# anyway, we won't focus our efforts on fixing this as a priority.

What I will do, however, is add a better warning message when the connection becomes invalidated in the build, so that it at least becomes easier to debug.