Monday, November 7, 2016

How Not to Crash

Pádraig Kennedy:

It’s good practice for programmers to figure out how to recreate crashes that they’re trying to fix. This can involve temporarily rewriting parts of the code to behave in an artificial way that makes the crash more likely. If we can reliably see the crash happen, it goes some distance to confirming suspicions and it gives us something to test potential fixes against. The alternative is to try a fix blindly, release it, and wait to see if we get crash reports.


In this case, I am aware of no way to trigger the suspension of an app that is connected to the debugger. In fact the debugger prevents suspension, and the simulators don’t accurately simulate it. Without the debugger, the only option is to experiment and then review logs on the device.


Apps that access files in a shared container while the app is running in the background should create a background task and not assume that the 30 second completion block time covers them. To work around this, developers can create a background task using the beginBackgroundTaskWithName:expirationHandler method on UIApplication and call endBackgroundTask when the background work is finished.


Additionally, Kevin also suggested that apps should close the database when they go into the background as a way to ensure they’ve finished flushing data and to surface rare bugs more reliably[…]

Comments RSS · Twitter

Leave a Comment