Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

IL2CPP Issue: PlatformInvoke::MarshalDelegate

Discussion in 'Scripting' started by LightStriker, May 17, 2018.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    We have to port 2 games to the Nintendo Switch.

    On one of them, we trigger this:

    Code (CSharp):
    1.         IL2CPP_ASSERT(d->method->methodDefinition);
    In the PlatformInvoke.cpp, method MarshalDelegate.

    We don't have a callstack or anything. Anybody has an idea on how to fix that?
     
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    I'm not sure why this would happen. It is related to marshaling of a managed function to a native function pointer, but this case should never occur. If the problem is reproducible, can you submit a bug report with this project?
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    We found out it was while passing a callback delegate to FMOD.
    We managed to make the callback work, somehow, no idea how. But it crashes right after with an even less useful message:

    Code (CSharp):
    1. Unhandled Exception Thrown: IL2CPPUnhandledException
    We commented just that callback out and everything works fine. (Except with no audio from FMOD). And the only thing that happens is the callback returns a FMOD_RESULT.OK.

    Right now, we have totally no idea how to fix it, but we will maybe send that to the FMOD people. :(
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Can you provide details about the function signature of the manged callback, and information about how the native method calls it? I suspect something is not correct with the p/invoke marshaling.

    Also, I'm not too familiar with Switch, but is it possible to get a native call stack when an exception occurs? If so, that would probably help determine the cause of this issue.