Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. 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,303
    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,273
    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,303
    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,273
    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.