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 Makes API Call Fail (Mono does not)

Discussion in 'Editor & General Support' started by BitGamey, Nov 4, 2019.

  1. BitGamey

    BitGamey

    Joined:
    Jun 11, 2016
    Posts:
    52
    Hi,

    I was about to release my facial recognition app onto the Google Play store when I discovered it needed to be a 64-bit build. Having developed my app using Mono in Unity 2019.2.11f1, I had no idea it would fail when I switched to IL2CPP.

    I don't get any errors, it just hangs at this line when running on a Samsung Galaxy:
    var res = await client.PublicModels.CelebrityModel.Predict(new ClarifaiFileImage(bytes)).ExecuteAsync();

    I have a Debug.Log statement before and after that line and when IL2CPP is selected, the Debug.Log never gets called after the line above.

    Are there any known issues with IL2CPP that might cause issues with using 'await' or API calls in general?

    The app works flawlessly using Mono. The only change I make is changing the dropdown to IL2CPP (so at this point I am not even selecting ARM64). It's so frustrating when what should have been a simple change before publishing is now preventing me from getting the app onto the store.

    Any suggestions, possible fixes or guidance on where to look would be appreciated before I have no hair left to pull out.

    Thanks in advance!
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    There is a known bug using await in il2cpp. Probably related. It's still being worked on.
     
    BitGamey likes this.
  3. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,921
    @Laniemme:

    Can you drop us a bug report with a project that reproduces this issue? I'd like to compare it to the bug report we currently have which is similar. This might be a slightly different issue.

    More generally, the async/await paradigm in C# generates a ton of extra code and GC allocations, so you may want to consider some other approach, if possible.
     
    BitGamey likes this.
  4. BitGamey

    BitGamey

    Joined:
    Jun 11, 2016
    Posts:
    52
    Thank you. Is there a code-around in the meantime?
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,921
    We don't have a work around, and I'm not sure this is the same as the reported problem anyway. I think the best option is to not use async/await at all, but that may not be feasible for your project.
     
    BitGamey likes this.
  6. BitGamey

    BitGamey

    Joined:
    Jun 11, 2016
    Posts:
    52