-
Notifications
You must be signed in to change notification settings - Fork 580
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dyld crash at launch #1246
Comments
Dynamic library sizes:
|
There is very few mentions about this crash that I could find, maybe because people don’t realise it is happening?
Sadly enough, two of those cases appear to get their app rejected, 1 followed up to say they recompiled and resubmitted and it was accepted. I bet that these were just cases of the reviewer’s device running out of memory and that the second case also got accepted after resubmitting. |
@JaviSoto had a discussion on twitter last week about the same issue but it looks like no solution surfaced. 🙁 |
@0xced Aye, he has let me know, it also sparked others chiming in. I have added a ‘Status’ section to the bottom of the OP. |
The jetsam/memory pressure process is described here for reference: http://newosxbook.com/articles/MemoryPressure.html If the issue can be reliably reproduced it may be worth testing explicit weak linking of some frameworks as described in SDK based development |
My radar has been closed as a duplicate of 24278648. |
@robinsenior Did you get any updates on your DTS? |
They initially told me it was fixed in 9.3, but an Apple dev on Twitter told me otherwise. I see crash logs for it in beta 7 but not the full release (AFAIK, I haven't checked in a few days). |
@robinsenior I have crash reports for 9.3 builds 13E233 and 13E234, so definitely not fixed. If you don’t have any atm and want to follow-up with DTS I can send you some. |
@alloy thanks; I just checked and we have some with those build numbers so I'll email them to DTS. As an aside, my phone is much faster under 9.3. The RAM clearing trick used to be essential just to get apps to launch quickly but now is unnecessary. Something related to reclaiming memory must have been fixed. |
Ace 👍
That’s great news! Might update my personal device sooner after all 😉 |
Apparently there have been some changes to dyld in 9.3 which resulted in significant performance improvements: https://github.com/stepanhruda/dyld-image-loading-performance |
Yeah, that’s about #586. |
Just got this update from DTS:
/facepalm |
Oh jeez… So their progress is basically all of what this ticket already describes ¯_(ツ)_/¯ I do get that they want to give you something that’s actionable for you right now, but it would have been nice to know a bit more what their status is on the real issue. (rdar://24278648, which is the one mine got closed in favour of.) |
Hi Alloy - Have you heard anything more about iOS dynamic library loading crasher? or are you guys making any changes to combine frameworks etc? |
@ctava Nope, if/when we would hear more, or decide a different course of action, it all goes public in this ticket. I don’t think combining frameworks would help, as it would probably still run out of memory and die in the same way. The only possibility to reduce (not fully get rid of) these issues would be to get rid of ‘fat’ (number of larger frameworks), which is not something we will be doing at this time. To summarise, imo it’s clearly a bug in iOS, and the radar that mine was closed in favour of is still open, so they haven’t ruled it as “works as intended” yet. Until that time, I don’t think the number of crashes vs the number of users warrants a lot of work on our part. YMMV. |
@robinsenior Thinking about that answer a bit more, could you ask them if they do in fact mean the number of libs vs the size of those libs? If they are positive that reducing the number of libs, regardless of size, is a way to workaround the issue, then that would definitely be helpful info. |
@alloy done. I'll keep you posted. |
Ace, thanks 👍 |
For another data point: we're seeing pretty commonly in our app as well since we switched to using dynamic frameworks with CocoaPods. We have 41 frameworks averaging about 1.5MB each. It's a pretty significant issue for us, so we're going back to a static library in our next release. |
@maxmeyers Are you using Swift yet? |
@alloy Fortunately not in production yet. |
@maxmeyers Ok cool. Just wanted to check if the Swift dylibs were not causing this issue for you, but that explains it then. Thanks for the feedback 👍 |
@alloy DTS says it's the number of libs, not the size. |
@robinsenior Well… that’s unexpected. Are you going to spend time on reducing the number of dynamic libs? |
We didn't have any Swift dependencies. One option might be to install your Swift frameworks with Carthage and use CocoaPods for Objective-C dependencies (that's assuming you're currently using CocoaPods to install your frameworks). |
@maxmeyers Do you use Swift in your app? If so, are you still getting this crash report (albeit in low numbers) due to libSwiftCore.dylib etc? |
No Swift at all. This crash has completely disappeared. |
Or you could use a second Podfile for your Swift dependencies and use something like Rome, if you prefer CocoaPods ;) |
@maxmeyers Ah, bugger, had hoped for an extra convincing case to Apple that shows that just using Swift leads to this issue. But great for you of course! |
@alloy: That wouldn't solve the issue though would it? Only reduce the likelihood of the crash because of less frameworks. Either way, unfortunately our app is 50% Swift so most of our pods are used in both 😞 |
@SquaredTiki Correct. |
Have any of you attempted to weak link frameworks and load them after launch using the NSBundle API? |
With that technique, it sounds like you're starting to move into some of the territory covered in this issue: #586 |
There are two, related issues at work here, both centering on the dynamic loader. Memory pressure and CPU. In the crash logs that I have seen memory pressure is the overriding concern. As the loader loads strongly linked frameworks at startup it has to verify their signatures. System processes involved in that increase memory pressure when it may have already been high on the device. The loader can't get enough memory to continue loading frameworks and their dependencies, the application can't be launched or is immediately terminated. Weak-linking the frameworks and loading after launch using the NSBundle API gives the developer more control over this process. Monitoring the performance of signature verification may also be helpful. |
Apple has told us that weak linking does not help the problem. |
We're having a similar problem and just wanted to reiterate the thanks for Artsy's open source ethos. This thread is very helpful. |
In order to reproduce this crash consistently, we downloaded a number of apps from the App Store on an iOS 9.3.1 device (iPhone 6+). I opened 14 apps, and when trying to open the 15th app, I experienced a crash on launch. From there, any app I tried to open for the first time would crash on launch, while previously opened apps would continue to launch successfully. I was able to reproduce this same sequence both after a reboot, and after manually killing all open apps via the app switcher. After upgrading the phone iOS version to 9.3.2 Beta 4, I was unable to reproduce any crash. At the maximum, I opened 50+ apps successfully. Hopefully this means the issue is fixed or at least ameliorated with iOS 9.3.2 Beta 4. |
@freshnitesh That’s great to hear, tanks for the update! |
@alloy Happy to help :) |
@freshnitesh thank you so much for the detailed instructions on how to reproduce the crash consistently. I'm also able to confirm that iOS 9.3.2 beta 4 fixes this issue. At some point, apps take longer to launch but no crash so far, which is way better. |
9.3.2 is out. So far nothing is crashing, but will keep an eye on this in the coming days/weeks. 🙏 for success. |
Yes, we believe the crashes on launch with mremap_encrypted -1 errno=12 are fixed in iOS 9.3.2 (as of beta 3, I think). Please file new bug reports if you see it again. |
Alright, I'm calling this 👏 👍 |
Awesome! 👏 |
This is great! 🚀 |
That's an amazing thread. |
Aside from the manual work shown in:
A new CocoaPods plugin has been created by @Ruenzuo since then that will automate most of that work: Other than that, there's no real choice to to write it off. At least 9.3 came with awesome emoji, and that got most of our users to update. |
TL;DR
This appears to happen when the device is out of memory, a restart of the device ‘fixes’ it. Presumably this neat trick does so as well.
Info about the errors
Known affected versions
These are the various versions for which we have crash reports.
iOS versions
dyld versions
Device versions
Retracing
mremap_encrypted
could return-1
is here.vn_getpath
callsbuild_path
, which in turn has a few possible locations where it could be returning-1
:mremap_encrypted
returns-1
, it most likely corresponds toERESTART
: https://github.com/opensource-apple/xnu/blob/2fa84067f6cdeb23267f877ca4fd26201316da1b/bsd/sys/errno.h#L270errno
is12
, it most likely corresponds toENOMEM
: https://github.com/opensource-apple/xnu/blob/2fa84067f6cdeb23267f877ca4fd26201316da1b/bsd/sys/errno.h#L102Caveats
Alas, the latest dyld sources to be released (at the time of writing) appear to be for version 360.18.
Taking a cursory look at the decompiled code for
ImageLoaderMachOCompressed::registerEncryption
from a firmware image for iOS 9.2 foriPad3,4
, does not appear to have any real changes.Conclusion
The crash at launch definitely feels like a very bad experience and I feel like iOS should handle this more gracefully. Maybe show an alert? Will have a think about this and possibly file a radar.
I’m not sure what/if we can do about this. We could probably improve it somewhat by trimming some framework fat from the bundle, but I don’t think these are large anyways.
It would be interesting to know if such failures occurred prior to iOS 9 and if they were labelled differently.
Status
The text was updated successfully, but these errors were encountered: