Search Unity

  1. Full schedule for #UniteBerlin is now available! Featuring talks on our roadmap, hands-on labs and much more! Check it out!
    Dismiss Notice
  2. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  3. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. 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
  6. 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,294
    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,109
    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,294
    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,109
    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.