I have an ios app which has not crashed in this way on ios 5 which is now crashing consistently on ios 6 on startup after 4 or 5 bg/fg cycles. I\'ve traced the issue to my invo
It turns out this has all been related to reallocating the ALAssetsLibrary for each sync. By adding a member variable instead, the crashing appears to have disappeared.
assetsLibrary = [[ALAssetsLibrary alloc] init];
While this is clearly a more efficient/better design for my code, I'd say the problems I've had indicate some ARC issue with ALAssetsLibrary and threading. Make sure to only allocate once!
You can checkout this. I have this problem before.But fix it by creating a singleton ALAssetsLibrary object
https://stackoverflow.com/a/32693118/3103450
I suffered same issue:
For short: While the ALAssetsLibrary
instance is enumerating with types or the ALAssetsGroup
instaces enumerated last step are enumerating assets, the ALAssetsLibrary
instance and the ALAssetsGroup
instances should never been changed before all the enumerating blocks are finished.
ALAssetsLibrary enumeration runs in the main thread (see this SO answer). I suspect this is because the assets library may want to interact with the user for permissions to use location data (because photos have geotagging).
This may be the source of your problem, if your code assumes that ALAssetsLibrary will continue to run in a background thread.