Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

IL2CPP Issue: PlatformInvoke::MarshalDelegate

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

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,347
    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:
    3,379
    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,347
    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:
    3,379
    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.