Search Unity

IL2CPP: Anyone else seeing MetadataCache::Initialize crashes sometimes when the game starts?

Discussion in 'Android' started by Prodigga, Jan 31, 2016.

  1. 357545146

    357545146

    Joined:
    Nov 1, 2017
    Posts:
    2
    I have follow you change, but also crash when create static framework from Classes,Libraries,Data. the dynamic framework is successful.
     
  2. muldercnc

    muldercnc

    Joined:
    Jun 22, 2013
    Posts:
    15
    caiovm
    Thanks you saved my bacon!
     
  3. mickee

    mickee

    Joined:
    Dec 26, 2013
    Posts:
    11
    Hi guys !

    Does any one has more info on how to get it working for a static framework ? I read the whole post but I am still getting an execution crash on the MetadataCache::Initialize call. I have initially followed the following tutorial (https://github.com/forestlin1212/unity-ios-framework) and I get the crash when sending an applicationDidFinishLaunchingWithOptions call in one of the framework function. In my test project, Data/ references the Data folder located in the framework project.

    Does making it a dynamic framework (dylib) could help ? (I am getting errors when switching framework type so it would take me some time to solve them)

    I described the whole issue in https://github.com/forestlin1212/unity-ios-framework/issues/7.

    I am using Unity 2017.4.1f1, Xcode 10.0.
     
  4. Kamick

    Kamick

    Joined:
    May 17, 2018
    Posts:
    1
    Hey guys. Have anyone tried doing that on 2017.4.7? Everything was working fine for me right until 2017.4.7f1. Now I get the same crash even with -DRUNTIME_IL2CPP=1 flag. And 2017.4.6 works just perfectly
     
  5. psydent

    psydent

    Joined:
    Feb 11, 2013
    Posts:
    12
    I checked in on this thread a few months ago but didn't re-waken it because it was by and large resolved. And fantastic with Unity 5.6.5p4.
    Now that more people are interested with newer Unity I'll chime in. I've reproduced this process to a science. I've built frameworks to integrate a Unity binary into other apps for several versions of Unity 5 and a few of Unity 2017, such as 2017.2.0f3 , including with Swift with a bridging header. Just tonight I got Unity 2018.1.0f2 working which was great because 2017.3/4 and 2018.2.0f2 had critical issues but my team is relying on them. Additionally we've taken steps to optimize the Unity framework size to make the artifact as small as possible. I decided to skip Carthage as a consumer but "disrupted" their paradigm https://github.com/Carthage/Carthage/issues/2485#issuecomment-402939286 - jokes on them because I can still be a binary provider.

    First thing, this is not and will never be a formal static library. Those do not support resources and Unity requires the Data folder. Therefore it will always be a dynamically linked library, specifically distributed as a framework.

    That said, I can provide guidance (warranty-free) about the build process and would appreciate help testing across different Unity builds for framework compatibility. I'd like to work with like-minded individuals who understand this is not supported by Unity BUT we may be able to ask for minor changes to support the effort. Right now I'm going to ping @JoshPeterson about elucidating why s_ManagedSectionEnd and the matching beginning in GetImageIndex can't load correctly in a 2018.2.0f2 framework build. I used symbolic breakpoints to watch over a hundred images load but still got a crash on that.

    Additionally there were view controller orientation crashes on Unity2017.3 and Unity2017.4. Unity 2017.2.0 was perfectly happy. What's up with that?
    *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [UnityDefaultViewController shouldAutorotate] is returning YES'
     
    Last edited: Aug 8, 2018
  6. psydent

    psydent

    Joined:
    Feb 11, 2013
    Posts:
    12
    There was a crash introduced into the engine initialization (as far as I can tell) that affected 2018.2+ and 2018.1.8+, but I filed a bug report and there is a fix that should make it out within the next 6 weeks: "It might make 2018.2.4, but it will definitely make 2018.2.5."
    I filed the bug as "Unity crashes in UnityInitApplicationNoGraphics" and it looks like it's being handled internally as
    [IL2CPP][iOS] Crash in il2cpp::eek:s::Image::Initialize() [inlined] il2cpp::eek:s::Image::InitializeManagedSection() at Image.cpp:81


    I think this is getting off-topic from the original point of this thread, so I won't comment further, but can be tagged in newer threads related to successfully getting a Unity framework created and integrated into an iOS app.
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,936
    This crash should only happen when Unity is embedded in another iOS application. Are you seeing it when Unity is running as a app on its own?
     
  8. psydent

    psydent

    Joined:
    Feb 11, 2013
    Posts:
    12
    JoshPeterson likes this.
  9. salgue

    salgue

    Joined:
    Jul 26, 2017
    Posts:
    2
    @UnknownRE gave us a really good hint by mentioning s_Il2CppCodegenRegistration()

    When s_Il2CppCodegenRegistration is included in UnityAppController.mm, the compiler won't strip symbols from Il2CppCodeRegistration.cpp in other words, the issue is that all symbols from Il2CppCodeRegistration.cpp get stripped from static libraries because nobody references them.

    An easier and less risky solution is to create a dummy method within UnityAppController.mm that calls
    s_Il2CppCodegenRegistration(); you shouldn't need to call this dummy method.

    People reporting that this works with a dylib is because symbols are probably not being stripped.

    Hope it helps,

    - Sal
     
  10. Nik_Kov

    Nik_Kov

    Joined:
    Nov 30, 2018
    Posts:
    3
    I just removed Data folder and add it again. And it works)
     
  11. U_tansuo

    U_tansuo

    Joined:
    Dec 6, 2013
    Posts:
    5
  12. U_tansuo

    U_tansuo

    Joined:
    Dec 6, 2013
    Posts:
    5
    I also have the same error I am using Unity 2018.1.3f1, Xcode 10.0.
     
  13. tonyqt

    tonyqt

    Joined:
    Jul 13, 2018
    Posts:
    1
    i solve this question by modify architectures. only leave arm64 , delete armv7
     
  14. HyunMok_Moon

    HyunMok_Moon

    Joined:
    Oct 14, 2016
    Posts:
    24
    I think there is a space (' ') between 'NSBundle' and 'bundleForClass'.

    Code (CSharp):
    1. NSBundle *bundle = [NSBundle bundleForClass:[self class]];
    2. UnityInitApplicationNoGraphics([[bundle bundlePath] UTF8String]);
    I can resolved EXC_BAD_ACCESS in this line, when I change to this code.
    Thanks.
     
  15. HyunMok_Moon

    HyunMok_Moon

    Joined:
    Oct 14, 2016
    Posts:
    24
    Hi Salgue,

    I met this EXC_BAD_ACCESS error in UnityInitApplicationNoGraphics when static library Mach-O type. But dynamic library is not error.
    How I can call s_Il2CppCodegenRegistration(); in UnityAppController.mm dummy method?
    Because I call this method, Undeclared identifier error. I included all kinds of cppcodegen related header files, but I can't call this method.

    BTW, When I use dynamic library, when I use UnitySendMessage("gameObj", "Method", "param"), I can not response from "gameObject", "Method" in unity.
    and my target platform is iOS, not android.

    Modified: I called s_Il2CppCodegenRegestration() through other method, but same error occued.
    EXC_BAD_ACCESS in
    il2cpp::vm::MetadataCache::Initialize()
    il2cpp::vm::Runtime::Init(char const*, char const*)
    ::Initialize2CppFromMain()
    UnityInitApplicationNoGrahpics



    Thank you
     
    Last edited: Apr 15, 2021