I am observing a crash on iOS14 device when I am using the new concurrency model in Xcode 13.2.1 which is backward compatible. The crash does not occur when I am running the code through Xcode but happens when I launch the app from home screen (without Xcode). I am providing a simple reproducible example which is crashing for me. I tried different workaround providing in this forum such as doable bitcode, linking lib swift_concurrency.tbd etc but no luck. I feel like I am missing something simple but don't know what it is. Any help please?
Does it crash in iOS 13/14 simulator ? Does it happen if you don't use concurrency but it's linked for ex a dependency define async interface but you don't call it ?
I don't have iOS 14 on hand and I'm afraid to push to production
Does it crash in iOS 13/14 simulator ?
No (both M1 and Intel). It only crashes in device and that too when not run through Xcode. Strangely it works fine when I run the code using Xcode. What gives?
Does it happen if you don't use concurrency but it's linked for ex a dependency define async interface but you don't call it ?
No crashes if the code is not called but exists in the codebase.
I have seen only one other report of this (via Feedback). In that report, the crash long implied that the concurrency back-deployment libraries either weren't in the installed app or weren't found at launch time. However, there wasn't enough there to reproduce the issue, and I haven't been able to reproduce this problem locally either. Various test projects that use async/await, as well as a fresh project with the view controller you provided, all work for me when launched on an iOS 14 device, whether from Xcode or from the home screen.
It might be something unexpected in your project or setup. Do you have a project you can share, here or via Feedback? Can you provide your build log so we can see whether, e.g., the appropriate back-deployment libraries are getting embedded into the app bundle?
I can confirm the above report - the app above works when launched in Xcode, crashes immediately upon launch (after a very brief screen flash) when launched from the phone, both debug & release versions. Same crash log. iOS 14.5, iPhone XS+, Xcode 13.2.1.
Edit: the app works when launched via simulator's home screen.
Not sure if this helps or not, but this sounds a lot like another crash I’ve seen with Xcode 13.2.1. Someone else posted with similar characteristics: https://developer.apple.com/forums/thread/697070
Backtrace suggests a crash inside the demangler
Crash only happens when compiled in release mode
Crash only occurs in iOS 14 (possibly earlier versions as well, but definitely not iOS 15)
Crash happens every time the relevant code is used (is not random)
Crash only happens when compiled with Xcode 13.2.1
Not exactly the same, as there was no concurrency near the call site for us - just SwiftUI with #available. We used the workaround in that dev forums post, so we’re no longer facing this issue. But I’m happy to supply crash logs or build logs via Feedback if it would help.
The app was created in a brand new project just now. In my log the entries are not symbolicated (no idea why) but I see the same addresses for the first 6 lines and otherwise the crash log is the same as what's above.
Thanks for testing the ViewController I provided. I am bit surprised that it did not crash for you on an iOS 14 device without Xcode, but it could potentially indicate that I could be missing something.
Please see below the project link which is crashing for me. This also contains build log where it suggests that --back-deploy-swift-concurrency is set and libswift_Concurrency.dylib seems to be deployed.
Same reproduces for me (Xcode 13.2.1). Any build from xcode (both debug and release) are crashing on launch from home screen on iOS 13-14 on any concurrency code. When launched in debug from xcode or build as archive and submitted to TF - works well.
Easily reproduced on simple project with just one async/await call.
Yep. You summed it up nicely @zavsby . I have not tested through Test Flight nor through adhoc builds and it is good to know it does not crash through Test Flight. I will try an adhoc build and see what happens.
I am curious to know why would it crash when launching release builds from Home Screen but not via TestFlight? Is optimizer playing a role and if so how?
After our short investigation I see that the difference between archived and build via debug is libswift_concurrency added into bundle. I've tried to replace libswift_concurrency in build folder (when build via xcode debug) with the library generated when archiving project (they have different size 1.1 MB vs 11MB) and rebuild app via xcode (it won't replace it in build folder until you make clean). In this case when I launch from home screen - it works.
So it's definitely linking or library issue.
Fascinating. The build log indicates that libswift_Concurrency.dylib is correctly being copied into the app in the right place. I see the same thing locally. For me, this app builds and works properly when launching it from the home screen on iOS 14.
Thanks for hanging with me as we try to figure out what's going on here... there are two next steps I can think of.
The first is if you can grab the built .app that's crashing for you. The log tells us that the library is being copied in, but it's possible that the executable isn't linking it correctly. By looking at the built app (specifically, the Test1 executable), we can see whether it's linking the concurrency library properly.
The second is that I wanted to ask more about your workflow. You build locally, and you run it from the home screen, but what's the step in between that transfers the built app to the device?
Do you have build logs and a built app for this? Build-via-debug should copy libswift_Concurrency.dylib into the app, always. If it isn't, that's a sure sign of a bug---either somewhere in the compiler (i.e., we're not referencing the library), linker (it's dropping the reference), or build system the copy of the library.
The size difference is because the original libswift_Concurrency.dylib contains bitcode (that's the ~11MB). When you build without archiving, the bitcode is stripped out of the library so the library is ~1MB.
Can't say for @jmuthialu, I do it this way: build and run app from Xcode (release or debug mode, doesn't matter) - it works. Stop the app (e.g. via Xcode, doesn't matter), launch the app from iPhone's home screen - doesn't work.
If I disable bitcode, and then try @zavsby 's trick of substituting the library taken from archive - the library is small indeed, and the trick doesn't work.
True. If I disable bitcode and make an archive - it also starts crashing from Home screen. It seems it somehow related to bitcode. I will attach all you’ve asked soon.
About iOS 13, I’ve tried on it and everything the same as for iOS 14. Btw it does not crash on simulator.
Also maybe important we are using M1 macs to compile.