Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

iOS EXC_BAD_ACCESS Crash

Discussion in 'Scripting' started by silentslack, Feb 17, 2022.

  1. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    355
    Hi,

    I'm running into a show stopping crash on iOS. Unity 2020.3.25f1. Trying to load scene using SceneManager.LoadScene() - even a empty scene is crashing with this stack trace:

    Code (CSharp):
    1. #include <UnityFramework/UnityFramework.h>
    2.  
    3. UnityFramework* UnityFrameworkLoad()
    4. {
    5.     NSString* bundlePath = nil;
    6.     bundlePath = [[NSBundle mainBundle] bundlePath];
    7.     bundlePath = [bundlePath stringByAppendingString: @"/Frameworks/UnityFramework.framework"];
    8.  
    9.     NSBundle* bundle = [NSBundle bundleWithPath: bundlePath];
    10.     if ([bundle isLoaded] == false) [bundle load];
    11.  
    12.     UnityFramework* ufw = [bundle.principalClass getInstance];
    13.     if (![ufw appController])
    14.     {
    15.         // unity is not initialized
    16.         [ufw setExecuteHeader: &_mh_execute_header];
    17.     }
    18.     return ufw;
    19. }
    20.  
    21. int main(int argc, char* argv[])
    22. {
    23.     @autoreleasepool
    24.     {
    25.         id ufw = UnityFrameworkLoad();
    26.         [ufw runUIApplicationMainWithArgc: argc argv: argv];
    27.         return 0;
    28.     }
    29. }
    30.  
    Code (CSharp):
    1. * thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x132)
    2.     frame #0: 0x0000000101df7988 UnityFramework`il2cpp::vm::Type::IsStruct(Il2CppType const*) + 88
    3.     frame #1: 0x0000000101de6df4 UnityFramework`il2cpp::vm::LivenessState::FieldCanContainReferences(FieldInfo*) + 24
    4.     frame #2: 0x0000000101de70e4 UnityFramework`il2cpp::vm::Liveness::FromStatics(void*) + 160
    5.     frame #3: 0x000000010141dd84 UnityFramework`GarbageCollectSharedAssets(bool, bool) + 1360
    6.     frame #4: 0x000000010142d224 UnityFramework`UnloadUnusedAssetsOperation::IntegrateMainThread() + 28
    7.     frame #5: 0x000000010142c48c UnityFramework`PreloadManager::UpdatePreloadingSingleStep(PreloadManager::UpdatePreloadingFlags, int) + 224
    8.     frame #6: 0x000000010142cbb4 UnityFramework`PreloadManager::WaitForAllAsyncOperationsToComplete() + 212
    9.     frame #7: 0x000000010141ec68 UnityFramework`ExecutePlayerLoop(NativePlayerLoopSystem*) + 100
    10.     frame #8: 0x000000010141eca8 UnityFramework`ExecutePlayerLoop(NativePlayerLoopSystem*) + 164
    11.     frame #9: 0x000000010141ef74 UnityFramework`PlayerLoop() + 272
    12.     frame #10: 0x0000000101906c58 UnityFramework`UnityPlayerLoopImpl(bool) + 112
    13.     frame #11: 0x0000000100ecd928 UnityFramework`-[UnityAppController(Rendering) repaint] + 108
    14.     frame #12: 0x0000000100ecd890 UnityFramework`-[UnityAppController(Rendering) repaintDisplayLink] + 108
    15.     frame #13: 0x0000000185e797b8 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 672
    16.     frame #14: 0x0000000185f587f4 QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 280
    17.     frame #15: 0x0000000182b680e0 CoreFoundation`__CFMachPortPerform + 176
    18.     frame #16: 0x0000000182b8d908 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
    19.     frame #17: 0x0000000182b8cc88 CoreFoundation`__CFRunLoopDoSource1 + 596
    20.     frame #18: 0x0000000182b8686c CoreFoundation`__CFRunLoopRun + 2372
    21.     frame #19: 0x0000000182b859f4 CoreFoundation`CFRunLoopRunSpecific + 600
    22.     frame #20: 0x000000019a25b734 GraphicsServices`GSEventRunModal + 164
    23.     frame #21: 0x000000018560475c UIKitCore`-[UIApplication _run] + 1072
    24.     frame #22: 0x0000000185609fcc UIKitCore`UIApplicationMain + 168
    25.     frame #23: 0x0000000100ecd374 UnityFramework`-[UnityFramework runUIApplicationMainWithArgc:argv:] + 108
    26.   * frame #24: 0x0000000100ae3e1c LuloClientTabatinga`main(argc=<unavailable>, argv=<unavailable>) at main.mm:26:9 [opt]
    27.     frame #25: 0x0000000182841cf8 libdyld.dylib`start + 4
    I've tried almost everything and can't get LoadScene to work. If I start the app with the target scene it is fine - it seems it is the call to SceneManager.LoadScene()...
     
    Last edited: Feb 18, 2022
  2. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    355
    I have tried:

    - In XCode setting 'optimization' to None
    - Adding '-mno-thumb ' flag: https://docs.unity3d.com/Manual/TroubleShootingIPhone.html
    - Adding 'yield return new WaitForEndOfFrame()' on SceneLoad: https://docs.unity3d.com/Manual/TroubleShootingIPhone.html
    - Removing 'Strip engine code' in project settings: https://forum.unity.com/threads/xcode-error-when-building-thread-1-exc_bad_access.802374/
    - Setting Development Build to true
    - Reducing to .NET Standard 2.0
    - Adding <optimize>false</optimize> to my managed plugins
    - Nuking the 'Library' folder and rebuilding
     
  3. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    355
    Sorry to bump this but still haven't got anywhere with this. Any pointers for things I could try to debug and provide more details? If the app crashes on SceneManager.LoadScene() for a blank scene, doesn't that suggest there is something wrong with that Unity function directly?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Have you updated to the latest XCode? You mention 2020.3.25f1, have you tried with other Unity versions? And you mention it happens with a new/empty project with just this minimal code? If so, you'll want to open a bug report. Please share the specific code you are using in a new project.
     
  5. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    355
    @JeffDUnity3D thank you for the help. XCode is the latest from the AppStore. I have only tried on 2020.3.25f1 - I will try updating to the latest on 2020 LTS. Thanks.
     
  6. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    355
    Ok updated to 2020.3.29 and the same issue:

    Screenshot 2022-02-24 at 16.06.05.png

    Just tested on Android and all seems ok - just iOS.
     
  7. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
    Did you fix that? Getting same crash on 2021.2.14f1...
     
  8. silentslack

    silentslack

    Joined:
    Apr 5, 2013
    Posts:
    355
    @manurocker95 sorry just getting back to you, I've yet to fix but was distracted by other projects. Any luck on your end?
     
  9. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
    Nope, still wondering wth happens because I thought it was some scripts with singleton pattern I made (in case the static instances broke xcode somehow) but after deleting those it continued happening so...

    Could it be Unity bug?
     
  10. soom5119

    soom5119

    Joined:
    May 17, 2022
    Posts:
    1
    Did you have solved this issue?
     
  11. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
    Nope, I reported the bug and Unity said they couldn't reproduce it...
     
  12. amonraduyev

    amonraduyev

    Joined:
    Apr 12, 2020
    Posts:
    9
    Did somebody fix it? We've been working on more than a week but we can not find any solution.
     
  13. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
    My report was successfully "confirmed" yesterday, so the fix should be on the go
     
  14. amonraduyev

    amonraduyev

    Joined:
    Apr 12, 2020
    Posts:
    9
    Well, we tried a device build and there are no errors! But still occures in simulator builds.

    1) In my case my Mac is M1 so I installed Unity 2021.3.3f1(m1) version and opened project with this version.
    2) (If you have) Uninstalled firebase from project and reimported.
    3) In XCode go to UnityFrameWork-General press "+" and add GameKit.
    4) Update Xcode latest version.
    5) Update device latest version.
     
  15. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    108
    Seems to happen as well for me.

    2021.3.2f1
    All default settings; "Run in Xcode = Latest, Run in Xcode as = Release"
    Exporting for Simulator SDK in Player Settings
    Application crashes at start-up when running from Xcode

    upload_2022-6-14_16-47-12.png
     
  16. aurasstudios

    aurasstudios

    Joined:
    Jan 24, 2022
    Posts:
    2
    Can you please share your bug report case id number so we can all keep a watch for the fix.
    Thank you.
     
  17. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    @KingKRoecks Did you find any workaround for this? I am also facing this issue and need a simulator build for Facebook approval.

    @manurocker95 Can you let us know if you found any solution for this or if Unity fixed your issue?
     
  18. Alirux

    Alirux

    Joined:
    Nov 27, 2014
    Posts:
    7
    Could you please share link to that report?
     
  19. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
  20. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
  21. nikoloz_astamidze_h

    nikoloz_astamidze_h

    Joined:
    Mar 12, 2019
    Posts:
    1
    @manurocker95 Thank you for Sharing

    Meantime, I figured out that indicated line by Xcode actually has nothing to do with the Crash. In my case issue was caused by one of the plugins. Stacktrace helped me to understand which plugin was causing the issue. For the test, I removed it from my project, built it again and the app starts normally now.

    To stack trace in Xcode, you can type lldb command 'down' a few times in the terminal and it will lead you to the actual method which causes the crash.
    From 4:00 you can find where to write lldb commands.



    This post helped as well - https://www.appypie.com/sigabrt-xcode-swift/
     
    madmar likes this.
  22. amonraduyev

    amonraduyev

    Joined:
    Apr 12, 2020
    Posts:
    9
    We finally fixed the issue.
    Thanks for that advice. With "bt" command I saw more about crash and in my case crash reason seem about textures(Not exact place of code). In Unity when building under "Asset Import Overrides section" (I think this section start to appear in Unity 2021 versions. I didn't see in 2020 version) adjust "Max Texture Size" to " Max 128" or whatever you want until crash gone. Now crash gone and everything is OK.

    WhatsApp Image 2022-06-27 at 05.58.10.jpeg
     
    Last edited: Jun 27, 2022
    berkay97yildiz likes this.
  23. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
    not working for me :/
     
  24. ByteStormGmbH

    ByteStormGmbH

    Joined:
    Mar 21, 2021
    Posts:
    12
    The idea is good but unfortunately only works for us with the setting Max 512x512. But we need 2048...
     
  25. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    For us, turns out it was a combination of one of our scripts for internet ping checking, and Firebase plugin which was causing this issue. We disabled this script and the Firebase game object for the simulator build and were able to take a working build. Since we needed it for Facebook verification only, disable these was not a problem for us.
     
  26. amonraduyev

    amonraduyev

    Joined:
    Apr 12, 2020
    Posts:
    9
    512X512 or a lower size is for Simulator builds. For device builds there is no issue with 2048X2048 or no override.
     
  27. ByteStormGmbH

    ByteStormGmbH

    Joined:
    Mar 21, 2021
    Posts:
    12
    According to Unity, the problem has been solved. Can you confirm this? We still have the problem with the new version 2021.3.9f1.

    Small Update : Strange... With Texture Compression Override to "Fore Uncompress" it runs on the simulator (12 Max 15.5)
     
    Last edited: Sep 12, 2022
  28. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
    It seems to be fixed if the project is not stored in external drive instead of the internal one
     
  29. huyonline456

    huyonline456

    Joined:
    Nov 19, 2020
    Posts:
    2

    I also have this problem, I tried your way but I can't understand what the terminal shows.
    "tid = 0x256fd 0x0000000104badf98 UnityFramework`ResourceCatalogData_GetGUIDFromPath_mB3F5A09EB3322F17012B64673BBB1C16D0A5C4A5 + 128"
    I found that bug caused by one of the package. But, i can not understand anything in the terminal of xCode. So I can't find out which package is causing the error in my project.
     
  30. huyonline456

    huyonline456

    Joined:
    Nov 19, 2020
    Posts:
    2
    ----- Unity 2021.3.8f1 -----
    Problem is solved for me
    I created a new project and added my project packages and tested. Then removing packages one by one and building to find the faulty package. Finally, I found the faulty package in my project. It's Unity's "Entities Preview package". I removed this package and the problem is solved
    https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/index.html
     
  31. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
  32. ruslansmax

    ruslansmax

    Joined:
    Mar 30, 2014
    Posts:
    1
    For me (2021.3.10f1.) all sprites compression set to "none" fixed the error
     
  33. manurocker95

    manurocker95

    Joined:
    Jun 14, 2016
    Posts:
    162
    Today I tried to compile from my external drive on 2021.3.12f1 and the error message is displayed but the build is performed so...
     
  34. scciobotaru

    scciobotaru

    Joined:
    Aug 6, 2021
    Posts:
    4
    Had the very same issue. In the end it was my code / game objects. Check closely your null pointers. I finally deleted some unused game objects and it worked.