Frequent error building game due to usage of FunctionPointer<>.Invoke (1.7.1 / 1.8.0-pre.1)

We’re making use of Burst-compiled FunctionPointers, however we are frequently and randomly getting errors when building the application that complain with the following error:

Unable to resolve the definition of the method Techblox.Serialization.Generic.SerializeComponentFunctionDelegate.Invoke(Svelto.ECS.EGID& modreq(System.Runtime.InteropServices.InAttribute), System.IntPtr& modreq(System.Runtime.InteropServices.InAttribute), Svelto.ECS.DataStructures.NativeDynamicArrayCast1<System.Byte>& modreq(System.Runtime.InteropServices.InAttribute), ref uint)`

The FunctionPointer is defined to use the following delegate:

    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    public delegate void SerializeComponentFunctionDelegate(in EGID egid, in IntPtr mapperPtr,
        in NativeDynamicArrayCast<byte> serializationData, ref uint dataPos);

It’s not clear whether there is anything in our set-up that is wrong, however the fact the error randomly shows up and we do not have any runtime errors from this code leads me to believe that it is an error in the Burst compiler. I’m unsure what information would be most useful to identify the actual problem, so please let me know if there’s anything else I can show or explain to help.

Which Burst version are you using?

Currently using 18.0-pre.1, but it also happens with 1.7.1

Can you provide a repro for this bug? It’s not something we’ve seen at least.

I’ll try to get a repro soon, the fact it doesn’t happen 100% of the time in builds will make it difficult but I suspect it’s something to do with calling FunctionPointer<>.Invoke from with a Burst-compiled function on the main thread (as in, not using the JobSystem and just using the BurstCompile attribute)

Have the same issue here! Did you manage to find a problem/solution?