14

Anyone encountered this error before when trying to access the photo library using the image picker?

NSInvalidArgumentException  Cannot set metadata in read-only store.

Any advise on what actually went wrong and suggestions on how I can resolve this will be greatly appreciated.

A snapshot of the error stack is shown below

enter image description here

Zhen
  • 12,361
  • 38
  • 122
  • 199
  • Can you show some lines of code that illustrate how you're setting up your UIImagePickerController? – Michael Dautermann Oct 10 '11 at 03:35
  • Did you figure this out? In my case it happens in production and I don't have the full log only "NSInvalidArgumentException: Cannot set metadata in read-only store." But it happens very infrequently. i.e. once out of more than 17000 sessions. – AmaltasCoder Oct 14 '11 at 11:20

2 Answers2

6

There's a post on the dev forums which might be slightly helpful (it's curiously marked "Apple Confidential Information" despite iOS 5 being released).

We've been seeing these too. My first impression was that it was related to using PhotoStream while not being connected to iCloud, but "recordVersion:forStore:" suggests it's trying to upgrade the photo library to the 5.0 format (which it presumably can't do as an unprivileged/sandboxed/etc process).

In addition to "sync with iTunes", the following things might fix the problem:

  • Launching Photos
  • Launching Camera and taking a picture

This doesn't seem to have been fixed in OS 5.0.1, but the number of reports has drastically reduced, suggesting people's photo libraries are eventually being upgraded.

tc.
  • 33,468
  • 5
  • 78
  • 96
4

This issue is IOS5 only- have asked Apple on the dev forums, but no answer. I have not been able to repro myself, but..

My beta testers reported that syncing with iTunes seems to clear this error up- so my guess is that iTunes sync is fixing a permissions problem.

I wrapped this code in a @try/@catch but it's still crashing :(.

- (void)showImagePicker {
 UIImagePickerController *imagePicker = [[[UIImagePickerController alloc] init] autorelease];     
 imagePicker.delegate = self;
 imagePicker.hidesBottomBarWhenPushed = YES;
 imagePicker.allowsEditing = YES;
 imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
 [tabController presentModalViewController:imagePicker animated:YES];  // sometimes crash 
}

also getting the same crash infrequently/non-reproducibly for other users when I call UIImageWriteToSavedPhotosAlbum

mr_marc
  • 111
  • 5