Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Enter the 2020.2 Beta Sweepstakes for a chance to win an Oculus Quest 2.
    Dismiss Notice

burst 1.4.0p4 e0.7 log spam "must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP"

Discussion in 'Data Oriented Technology Stack' started by eatbuckshot, Mar 4, 2020.

  1. eatbuckshot

    eatbuckshot

    Joined:
    Jan 10, 2016
    Posts:
    19
    Edit: as per #2, yes it's from upgrading to burst 1.3.0-preview.4 I believe
    I've upgraded to Unity Entities 0.7.0 on the DOTSSample project and noticed I now get this error message on many methods when I build (with mono set )
    Code (CSharp):
    1. 2: The method `Int32 BeginSendMessage(Unity.Networking.Transport.NetworkInterfaceSendHandle ByRef, IntPtr)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    2. 2: The method `Int32 EndSendMessage(Unity.Networking.Transport.NetworkInterfaceSendHandle ByRef, Unity.Networking.Transport.NetworkInterfaceEndPoint ByRef, IntPtr, Unity.Networking.Transport.NetworkSendQueueHandle ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    3. 2: The method `Void AbortSendMessage(Unity.Networking.Transport.NetworkInterfaceSendHandle ByRef, IntPtr)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    4. 2: The method `Void Receive(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundRecvBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    5. 2: The method `Void Send(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundSendBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    6. 2: The method `Void InitializeConnection(Byte*, Int32, Byte*, Int32, Byte*, Int32, Byte*, Int32)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    7. 2: The method `Void Receive(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundRecvBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    8. 2: The method `Void Send(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundSendBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    9. 2: The method `Void InitializeConnection(Byte*, Int32, Byte*, Int32, Byte*, Int32, Byte*, Int32)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    10. 2: The method `Void Receive(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundRecvBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    11. 2: The method `Void Send(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundSendBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    12. 2: The method `Void InitializeConnection(Byte*, Int32, Byte*, Int32, Byte*, Int32, Byte*, Int32)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    13. 2: The method `Void Receive(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundRecvBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    14. 2: The method `Void Send(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundSendBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    15. 2: The method `Void InitializeConnection(Byte*, Int32, Byte*, Int32, Byte*, Int32, Byte*, Int32)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    16. 2: The method `Void Receive(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundRecvBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    17. 2: The method `Void Send(Unity.Networking.Transport.NetworkPipelineContext ByRef, Unity.Networking.Transport.InboundSendBuffer ByRef, Requests ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    18. 2: The method `Void InitializeConnection(Byte*, Int32, Byte*, Int32, Byte*, Int32, Byte*, Int32)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    19. 2: The method `Void InvokeExecute(Parameters ByRef)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    Code (CSharp):
    1. 63: The method `Void RunWithoutJobSystem(Unity.Entities.ArchetypeChunkIterator*, Void*)` must have `MonoPInvokeCallback` attribute to be compatible with IL2CPP!
    and this one many times
     
    Last edited: Mar 4, 2020
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    1,783
    I updated to Burst to 1.3.0 preview 4 and tried it out while still having Entities at 0.6.0 and I also get this just by entering playmode. Also I consistently crash the editor when stepping a frame in playmode. Happens when I set the Project settings to il2cpp or mono.
     
    eatbuckshot likes this.
  3. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    2,558
    I have a few other issues.

    Terrible performance on NativeArray.CopyTo - takes 35ms on a 1million length array in a burst job. Turning off burst makes it take a fraction of the time.

    Collections + entities + 0.7 seem to throw not unmanaged type when adding to a native stream, even if the struct is unmanaged...

    needless to say, we have deferred our upgrade.
     
    eatbuckshot likes this.
  4. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    1,814
    From Burst 1.3.0-preview.4 changelog:
     
    eatbuckshot likes this.
  5. eatbuckshot

    eatbuckshot

    Joined:
    Jan 10, 2016
    Posts:
    19
    I see that though was puzzled that it would print regardless if IL2CPP is chosen
     
  6. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    296
    These messages were a shorterm solution to address the issue that IL2CPP + Burst and function pointers would throw an exception at runtime.

    We have a longer term solution to not require this attribute anymore, but it can't be fixed in a few days.

    But we agree that these messages can be very annoying, specially if your project is not using IL2CPP. We are going to emit these messages only when building a player with IL2CPP. The fix should be part of the next preview.
     
    eatbuckshot and pal_trefall like this.
  7. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    104
    Just to check - you mean that preview.4 was a regression over preview.3 in this regard? I'm going to have a dig and see whats up.
     
    eatbuckshot and pal_trefall like this.
  8. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    2,558
    1.3 regression over 1.2.3

    Haven't tested p3, p2 was broken for us so we were waiting.

    Was simply a native array copy to native array of type byte. Nothing else in job (allocation or anything).

    Will post exact code when I get to work in like 6 hours.
     
    sheredom likes this.
  9. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    1,783
    Crash only happens in p4 for me, and only happens with safety checks disabled. (Safety checks disabled in p3 work normally). Case is 1124920
     
  10. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    104
    And just to check - was this with a player build or in the editor?
     
  11. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    2,558
    Editor (with all safety checks off, job debugger etc). We didn't get around to pushing it to build server before I reverted upgrade so I did not check.

    Be at work in 90min, but from memory the job just looked something like this

    Code (CSharp):
    1. [BurstCompile]
    2. public struct CopyJob : IJob {
    3.  
    4.    // Length 1024x1024
    5.    public NativeArray<float> Array1;
    6.    public NativeArray<float> Array2;
    7.  
    8.    public void Execute()
    9.    {
    10.        Array1.CopyTo(Array2);
    11.    }
    12. }
    Very simple, should just be a memcpy but was taking 35ms on a 3700x.
    Turning off burst on the job made it take less than 2ms.
     
    Last edited: Mar 4, 2020
    sheredom likes this.
  12. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    104
    @tertle ok I've worked it out - bit of a pain and sorry for the inconvience. I fixed two interrelated bugs in 1.3.0.preview.4 around memcpy/memset, the first was that we were calling out to the Unity engines memcpy instead of using the LLVM intrinsic which meant we missed a bunch of optimizations, and the second was that we weren't using memcpy to move large structs around when stack-allocated.

    It looks like the combination of these changes meant that sometimes we were calling out to our backup / probably don't want to run this as its scalar memcpy implementation and that's what your example is calling.

    I've got a fix locally, should be in preview.5.
     
    eatbuckshot, Sarkahn, mkracik and 5 others like this.
  13. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    569
    Is there any documentation for this attribute? How can I solve it?
     
  14. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    104
    The case you referenced doesn't look like a Burst bug - can you check it is the right one for me please?
     
  15. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    1,783
    1124920 Crash after long lag with Burst
    I submitted this bug on the first crash before I knew the culprit and before I knew I was going to reproduce it consistently. The long lag was due to a bug in CollisionConversionSystem.cs, but the crashes still happen even with that bug fixed. That system isn't required to run and reproduce the crash.

    Even after a major refactor I made last night where I switched a bunch of stuff from using UnsafeUtility to using StructLayout Explicit, I'm still reproducing the issue this morning. If you can't reproduce it with the benchmark project I sent you last week, I can try and send you the latest version. Its the same scene, same project, same workflow. Crashes on the second frame before I ever see profiler data.
     
  16. Kalinon

    Kalinon

    Joined:
    Aug 21, 2015
    Posts:
    1
    All i found was this: https://docs.microsoft.com/en-us/do...vokecallbackattribute?view=xamarin-ios-sdk-12 but i am also curious on how to correctly set this attribute.

    Using the GoInGameRequest example, It throws this warning for both InvokeExecute and CompileExecute

    Code (CSharp):
    1.     // RPC request from client to server for game to go "in game" and send snapshot / inputs
    2.     [BurstCompile]
    3.     public struct GoInGameRequest : IRpcCommand {
    4.         // Test int value
    5.         public int value;
    6.  
    7.         public void Serialize(ref DataStreamWriter writer) {
    8.             writer.WriteInt(value);
    9.         }
    10.  
    11.         public void Deserialize(ref DataStreamReader reader) {
    12.             value = reader.ReadInt();
    13.         }
    14.  
    15.         [BurstCompile]
    16.         private static void InvokeExecute(ref RpcExecutor.Parameters parameters) {
    17.             RpcExecutor.ExecuteCreateRequestComponent<GoInGameRequest>(ref parameters);
    18.         }
    19.  
    20.         public PortableFunctionPointer<RpcExecutor.ExecuteDelegate> CompileExecute() {
    21.             return new PortableFunctionPointer<RpcExecutor.ExecuteDelegate>(InvokeExecute);
    22.         }
    23.     }
    I dont like guessing, but something like this?


    Code (CSharp):
    1.         [BurstCompile, MonoPInvokeCallback(typeof(PortableFunctionPointer<RpcExecutor.ExecuteDelegate>))]
    2.         private static void InvokeExecute(ref RpcExecutor.Parameters parameters) {
    3.             RpcExecutor.ExecuteCreateRequestComponent<GoInGameRequest>(ref parameters);
    4.         }
    But i have no idea for CompileExecute.
     
  17. drhodor

    drhodor

    Joined:
    Aug 18, 2013
    Posts:
    39
    Am getting this too with the Netcode samples. When _running_ my server.

    Burst 1.3.0 preview 11
    Entities 0.9.1 preview 15
     
unityunity