Large Images Crash iOS

While I’ve reported the bug to Apple, I thought I would pass along a problem I found in iOS. I have only tested this in iOS 9.3.1. Basically, using a large PNG image in a UIImageView can cause iOS to crash on some devices. It works fine in the simulator. I have created a simple iOS app in Objective-C to demonstrate the bug.

What Happens

If you use a large PNG image in a UIImageView, attempting to display the image can cause the iOS device to crash and reboot. Yes, you read that right: the operating system will crash and the device will have to restart.

The app I created has 3 views: a main view that you start on startup, and two views that you reach by tapping on one of the two buttons in the main view.

TestCrash Main

If you tap on the “Small Image” button, the app navigates to the other view just fine. If you tap on the “Large Image” button, the app will hang briefly, then the device will restart. The image used in the app is a 2048 x 2048 PNG file.

This behaviour only appears to happen on older hardware. If you run the app inside the Simulator, it works just fine. In my testing, I ran it on an iPhone 4S (model A1387) and an iPad Mini Retina (model A1489) and it crashes pretty consistently. Running it on an iPhone 6 Plus (model A1522) doesn’t seem to be a problem.

I tried running this with and without the debugger attached. I also put a breakpoint in the didReceiveMemoryWarning method to see if it at least tried to get the app to fix things, but it never reached that point in the code.

The solution for now is to use smaller images. Moving to an image under 200×200 appears to make the problem go away.


One thought on “Large Images Crash iOS

  1. Pingback: My Newest App Now Available | Thoughts from Geoff Kratz @ FarWest Software

Comments are closed.