Camera issues!

I’ve known since the start that the UIImagePickerControllerDelegate code I was using was deprecated so I’ve finally gone through and updated it. The changes were implemented to allow support for video I believe not that I’ll be needed those extensions. It’s still a good idea not to have deprecated code lying around as it will bite you eventually.
Whilst making these changes I decided it was time to allow the app to use photos taken with the camera directly. The changes are as simple as setting a property to a different value so I expected no trouble. Yet…. the app quietly terminates when the camera is opened. No obvious exception is thrown. Looking at the stack in the app crash logs on the iphone you see this:

9 libobjc.A.dylib 0x00004838 objc_exception_throw + 64
10 CoreFoundation 0x0009fd0e +[NSException raise:format:arguments:] + 62
11 CoreFoundation 0x0009fd48 +[NSException raise:format:] + 28
12 Foundation 0x00031bd6 -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 538
13 Foundation 0x0003192a -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 114
14 Cooking Companion 0x0000bb42 0x1000 + 43842
15 UIKit 0x0008cab4 -[UIViewController unloadViewForced:] + 132
16 UIKit 0x0008ca22 -[UIViewController unloadViewIfReloadable] + 10
17 UIKit 0x0008c966 -[UINavigationController purgeMemoryForReason:] + 94
18 UIKit 0x0008c896 -[UIViewController didReceiveMemoryWarning] + 10
19 UIKit 0x0008c880 -[UIViewController _didReceiveMemoryWarning:] + 8

So it get’s a memory warning and bugs out. Crap. 🙁 Performance Tool to the rescue!

— Edit —

Performance Tool Tracking Memory Allocations

Performance Tool Tracking Memory Allocations

Odd. Time to capture warning events then.

— Second Edit —

OK it even throws a memory warning for the photo picker in both the simulator and on the phone itself despite consuming less than 2MB of memory. The difference being that the photo picker doesn’t crash out. If I choose to take a photo with the camera the same memory warning is issued but it crashes. You can’t test that in the simulator as there’s no ’emulated’ camera. What on earth is going on here? It would appear that I’m not the only one with the issue and it may well be something related to how the controller is presented. For example in this case you can present it with many ‘objects’ as the parent:

The view itself.
The navigationConroller.
The tabbarController.
The main app view (wha? why would you even…)

— Final Edit —

It was other apps running on my phone causing the crash. Still doesn’t explain the memory warning being thrown on the simulator. I checked and rechecked, total memory usage for even the most intensive view was ~6MB so nowhere near the limits. The images used in recipe steps could be the most intensive but I’m working on squishing those down to reasonable resolutions (taking the iPhone 4 into account). I know I should really save them to disk and keep them out of Core Data but it’s such a hassle to manage.

This entry was posted in Programming. Bookmark the permalink.

2 Responses to Camera issues!

Comments are closed.