iOS EXC_BAD_ACCESS Crash

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:

#include <UnityFramework/UnityFramework.h>

UnityFramework* UnityFrameworkLoad()
{
    NSString* bundlePath = nil;
    bundlePath = [[NSBundle mainBundle] bundlePath];
    bundlePath = [bundlePath stringByAppendingString: @"/Frameworks/UnityFramework.framework"];

    NSBundle* bundle = [NSBundle bundleWithPath: bundlePath];
    if ([bundle isLoaded] == false) [bundle load];

    UnityFramework* ufw = [bundle.principalClass getInstance];
    if (![ufw appController])
    {
        // unity is not initialized
        [ufw setExecuteHeader: &_mh_execute_header];
    }
    return ufw;
}

int main(int argc, char* argv[])
{
    @autoreleasepool
    {
        id ufw = UnityFrameworkLoad();
        [ufw runUIApplicationMainWithArgc: argc argv: argv];
        return 0;
    }
}
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x132)
    frame #0: 0x0000000101df7988 UnityFramework`il2cpp::vm::Type::IsStruct(Il2CppType const*) + 88
    frame #1: 0x0000000101de6df4 UnityFramework`il2cpp::vm::LivenessState::FieldCanContainReferences(FieldInfo*) + 24
    frame #2: 0x0000000101de70e4 UnityFramework`il2cpp::vm::Liveness::FromStatics(void*) + 160
    frame #3: 0x000000010141dd84 UnityFramework`GarbageCollectSharedAssets(bool, bool) + 1360
    frame #4: 0x000000010142d224 UnityFramework`UnloadUnusedAssetsOperation::IntegrateMainThread() + 28
    frame #5: 0x000000010142c48c UnityFramework`PreloadManager::UpdatePreloadingSingleStep(PreloadManager::UpdatePreloadingFlags, int) + 224
    frame #6: 0x000000010142cbb4 UnityFramework`PreloadManager::WaitForAllAsyncOperationsToComplete() + 212
    frame #7: 0x000000010141ec68 UnityFramework`ExecutePlayerLoop(NativePlayerLoopSystem*) + 100
    frame #8: 0x000000010141eca8 UnityFramework`ExecutePlayerLoop(NativePlayerLoopSystem*) + 164
    frame #9: 0x000000010141ef74 UnityFramework`PlayerLoop() + 272
    frame #10: 0x0000000101906c58 UnityFramework`UnityPlayerLoopImpl(bool) + 112
    frame #11: 0x0000000100ecd928 UnityFramework`-[UnityAppController(Rendering) repaint] + 108
    frame #12: 0x0000000100ecd890 UnityFramework`-[UnityAppController(Rendering) repaintDisplayLink] + 108
    frame #13: 0x0000000185e797b8 QuartzCore`CA::smile:isplay::smile:isplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 672
    frame #14: 0x0000000185f587f4 QuartzCore`display_timer_callback(__CFMachPort*, void*, long, void*) + 280
    frame #15: 0x0000000182b680e0 CoreFoundation`__CFMachPortPerform + 176
    frame #16: 0x0000000182b8d908 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 60
    frame #17: 0x0000000182b8cc88 CoreFoundation`__CFRunLoopDoSource1 + 596
    frame #18: 0x0000000182b8686c CoreFoundation`__CFRunLoopRun + 2372
    frame #19: 0x0000000182b859f4 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #20: 0x000000019a25b734 GraphicsServices`GSEventRunModal + 164
    frame #21: 0x000000018560475c UIKitCore`-[UIApplication _run] + 1072
    frame #22: 0x0000000185609fcc UIKitCore`UIApplicationMain + 168
    frame #23: 0x0000000100ecd374 UnityFramework`-[UnityFramework runUIApplicationMainWithArgc:argv:] + 108
  * frame #24: 0x0000000100ae3e1c LuloClientTabatinga`main(argc=<unavailable>, argv=<unavailable>) at main.mm:26:9 [opt]
    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()…

1 Like

I have tried:

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?

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.

@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.

Ok updated to 2020.3.29 and the same issue:

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

1 Like

Did you fix that? Getting same crash on 2021.2.14f1…

@manurocker95 sorry just getting back to you, I’ve yet to fix but was distracted by other projects. Any luck on your end?

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?

Did you have solved this issue?

Nope, I reported the bug and Unity said they couldn’t reproduce it…

Did somebody fix it? We’ve been working on more than a week but we can not find any solution.

My report was successfully “confirmed” yesterday, so the fix should be on the go

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.
1 Like

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

3 Likes

Can you please share your bug report case id number so we can all keep a watch for the fix.
Thank you.

@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?

Could you please share link to that report?

Unity Issue Tracker - [iOS] EXC_BAD_ACCESS crash when deploying to iOS 15 (unity3d.com)