I've been facing in the last days a very weird and specific issue under iPhone 3GS running iOS 4.0.1.
I have a UIImagePicker whereas a user can select either a picture or a video file. After that, I generate a thumbnail image from that media source. For pictures, it is working fine, however, for videos, I always get a EXC_BAD_ACCESS
after calling the thumbnailImageAtTime
method.
This is the code I'm using:
NSURL* contentURL = [NSURL URLWithString:_videoFilePath];
_moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:contentURL];
[_moviePlayerController setShouldAutoplay:NO];
[_moviePlayerController setCurrentPlaybackTime:(NSTimeInterval)1];
[_moviePlayerController setInitialPlaybackTime:(NSTimeInterval)1];
[_moviePlayerController setControlStyle:MPMovieControlStyleNone];
[_moviePlayerController setMovieControlMode:MPMovieControlStyleNone];
videoThumb = [[_moviePlayerController thumbnailImageAtTime:(NSTimeInterval)1 timeOption:MPMovieTimeOptionNearestKeyFrame] retain];
[_moviePlayerController setCurrentPlaybackTime:(NSTimeInterval)-1];
[_moviePlayerController stop];
[_moviePlayerController release];
The above code runs on a separate thread through a NSOperationQueue
. I can have multiple thumbnail generation requests queued, but only one can run at any given time. The queue is configured with a maxConcurrentOperationCount
of 1
From the tests I was able to make, this issue only happens on iOS 4.0.1. Running iOS 4.0, 4.1, 4.2 and 4.2.1 does not reproduce such error. I cannot @try @catch
this error also.
Anyone knows or have any lights on what this might be? Or what to look for? I've been struggling on this for several days now.
Date/Time: 2011-02-06 11:14:01 -0200
OS Version: iPhone OS 4.0.1 (8A293)
Report Version: 104
Exception Type: SIGBUS
Exception Codes: BUS_ADRALN at 0x2c
Crashed Thread: 0
Thread 0 Crashed:
0 MediaToolbox 0x0003b6b0 FigMediaValidatorCopyByteStream + 4
1 Celestial 0x00014c35 -[AVFileValidator notificationForFileCheckResult:] + 281
2 Celestial 0x000146fb -[AVFileValidator postNotificationForCallback:] + 35
3 CoreFoundation 0x000277ff -[NSObject(NSObject) performSelector:withObject:] + 23
4 Celestial 0x000094a5 -[AVObjectRegistry safeInvokeWithDescription:] + 125
5 CoreFoundation 0x000277ff -[NSObject(NSObject) performSelector:withObject:] + 23
6 Foundation 0x00090bbd __NSThreadPerformPerform + 269
7 CoreFoundation 0x00071a8d __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 13
8 CoreFoundation 0x0007376f __CFRunLoopDoSources0 + 383
9 CoreFoundation 0x0007450b __CFRunLoopRun + 231
10 CoreFoundation 0x0001d8eb CFRunLoopRunSpecific + 231
11 CoreFoundation 0x0001d7f3 CFRunLoopRunInMode + 59
12 GraphicsServices 0x000036ef GSEventRunModal + 115
13 GraphicsServices 0x0000379b GSEventRun + 63
14 UIKit 0x000062a7 -[UIApplication _run] + 403
15 UIKit 0x00004e17 UIApplicationMain + 671
16 App 0x000035ef 0x1000 + 9711
Thread 1:
0 libSystem.B.dylib 0x0002dc4c kevent + 24
1 libSystem.B.dylib 0x000d689c _dispatch_queue_invoke + 104
2 libSystem.B.dylib 0x000d6a3c _dispatch_worker_thread2 + 128
3 libSystem.B.dylib 0x0007ad89 _pthread_wqthread + 265
Thread 2:
0 libSystem.B.dylib 0x00001658 mach_msg_trap + 20
1 CoreFoundation 0x000722cf __CFRunLoopServiceMachPort + 95
2 CoreFoundation 0x00074589 __CFRunLoopRun + 357
3 CoreFoundation 0x0001d8eb CFRunLoopRunSpecific + 231
4 CoreFoundation 0x0001d7f3 CFRunLoopRunInMode + 59
5 WebCore 0x0000305d RunWebThread(void*) + 369
6 libSystem.B.dylib 0x0007a98d _pthread_start + 249
Thread 3:
0 libSystem.B.dylib 0x00001658 mach_msg_trap + 20
1 CoreFoundation 0x000722cf __CFRunLoopServiceMachPort + 95
2 CoreFoundation 0x00074589 __CFRunLoopRun + 357
3 CoreFoundation 0x0001d8eb CFRunLoopRunSpecific + 231
4 CoreFoundation 0x0001d7f3 CFRunLoopRunInMode + 59
5 Foundation 0x0003b725 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 213
6 Foundation 0x0000bc9d -[NSThread main] + 45
7 Foundation 0x000909e1 __NSThread__main__ + 973
8 libSystem.B.dylib 0x0007a98d _pthread_start + 249
Thread 4:
0 libSystem.B.dylib 0x00025a20 select$DARWIN_EXTSN + 20
1 libSystem.B.dylib 0x0007a98d _pthread_start + 249
Thread 5:
0 libSystem.B.dylib 0x000798dc __semwait_signal + 24
1 libSystem.B.dylib 0x0002e639 pthread_cond_wait + 33
2 CoreMedia 0x00002f1b WaitOnCondition + 11
3 CoreMedia 0x00002e61 FigSemaphoreWaitRelative + 73
4 MediaToolbox 0x00003e4b fpa_AsyncMovieControlThread + 55
5 CoreMedia 0x0001e4c3 figThreadMain + 139
6 libSystem.B.dylib 0x0007a98d _pthread_start + 249
Thread 6:
0 libSystem.B.dylib 0x00001658 mach_msg_trap + 20
1 MediaToolbox 0x00008b0b FigExpressNotificationThread + 43
2 CoreMedia 0x0001e4c3 figThreadMain + 139
3 libSystem.B.dylib 0x0007a98d _pthread_start + 249
Thread 7:
0 libSystem.B.dylib 0x000798dc __semwait_signal + 24
1 libSystem.B.dylib 0x0002e639 pthread_cond_wait + 33
2 CoreMedia 0x00002f1b WaitOnCondition + 11
3 CoreMedia 0x00002e61 FigSemaphoreWaitRelative + 73
4 MediaToolbox 0x00003e4b fpa_AsyncMovieControlThread + 55
5 CoreMedia 0x0001e4c3 figThreadMain + 139
6 libSystem.B.dylib 0x0007a98d _pthread_start + 249
Thread 8:
0 libSystem.B.dylib 0x000016cc semaphore_timedwait_signal_trap + 8
1 libSystem.B.dylib 0x0002ea07 _pthread_cond_wait + 679
2 libSystem.B.dylib 0x0002f5b9 pthread_cond_timedwait_relative_np + 17
3 CoreMedia 0x00002e7f FigSemaphoreWaitRelative + 103
4 MediaToolbox 0x000bfb53 FigMediaValidatorValidateAsyncInternal + 399
5 MediaToolbox 0x00038a0d FigMediaValidatorCreate + 53
6 Celestial 0x00015093 -[AVFileValidator validateBlocking:] + 303
7 Celestial 0x0000beb1 -[AVFileValidator validate] + 17
8 MediaPlayer 0x0006ead3 -[MPMovie _determineMediaType] + 335
9 Foundation 0x00086c8d __NSFireDelayedPerform + 369
10 CoreFoundation 0x00071a5b __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 15
11 CoreFoundation 0x00073ee5 __CFRunLoopDoTimer + 861
12 CoreFoundation 0x00074865 __CFRunLoopRun + 1089
13 CoreFoundation 0x0001d8eb CFRunLoopRunSpecific + 231
14 CoreFoundation 0x0001d7f3 CFRunLoopRunInMode + 59
15 Foundation 0x00004d67 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 203
16 Foundation 0x000863bf -[NSRunLoop(NSRunLoop) runUntilDate:] + 63
17 MediaPlayer 0x0000e927 -[MPMoviePlayerControllerNew thumbnailImageAtTime:timeOption:] + 119
18 CoreFoundation 0x0009f074 __invoking___ + 68
19 CoreFoundation 0x0003270d -[NSInvocation invoke] + 109
20 MediaPlayer 0x0000bd7f -[MPMoviePlayerController forwardInvocation:] + 47
21 CoreFoundation 0x0009ef59 ___forwarding___ + 577
22 CoreFoundation 0x00031680 _CF_forwarding_prep_0 + 48
23 App 0x0004f94f 0x1000 + 321871
24 Foundation 0x0000dd1b -[__NSOperationInternal start] + 659
25 Foundation 0x0000da7f -[NSOperation start] + 23
26 Foundation 0x0007e5bb ____startOperations_block_invoke_2 + 47
27 libSystem.B.dylib 0x000d5c5c _dispatch_call_block_and_release + 20
28 libSystem.B.dylib 0x000d6a3c _dispatch_worker_thread2 + 128
29 libSystem.B.dylib 0x0007ad89 _pthread_wqthread + 265
Thread 9:
0 libSystem.B.dylib 0x0007b85c __workq_kernreturn + 8
Thread 0 crashed with ARM (Native) Thread State:
r0: 0x00000000 r1: 0x064386ec r2: 0x06436fa0 r3: 0x00000004
r4: 0x30c178e0 r5: 0x00000000 r6: 0x332d1074 r7: 0x2fffeb20
r8: 0x06434e40 r9: 0x2fffeafc r10: 0x00000000 r11: 0x3e1e1ae0
r12: 0x3e1da394 sp: 0x2fffeb1c lr: 0x30ba0c35 pc: 0x307a86b0
------ EDIT
On another execution, a different stack has arisen:
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000286c objc_msgSend + 16
1 Celestial 0x0001b025 -[AVPlaybackItem release] + 73
2 Celestial 0x00005d71 -[AVPlaybackQueue queueItemWasAddedNotification:] + 473
3 Foundation 0x00018fb7 _nsnote_callback + 143
4 CoreFoundation 0x00069e73 __CFXNotificationPost_old + 403
5 CoreFoundation 0x0001a37b _CFXNotificationPostNotification + 119
6 Foundation 0x000040c3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 71
7 Celestial 0x00005b67 -[AVQueue itemWasAdded:atIndex:] + 127
8 Celestial 0x00005a01 -[AVQueue insertItem:atIndex:error:] + 157
9 Celestial 0x0000594f -[AVQueue appendItem:error:] + 47
10 Celestial 0x000051bb -[AVController addNextFeederItemToQueue] + 199
11 Celestial 0x000050d7 -[AVController checkQueueSpace] + 111
12 Celestial 0x000024d1 -[AVController setQueue:] + 101
13 Celestial 0x00004cb1 -[AVController setQueueFeeder:withIndex:] + 301
14 MediaPlayer 0x0001f999 -[MPAVController _setAVControllerQueueFeeder:startQueueIndex:] + 97
15 MediaPlayer 0x0001e53d -[MPAVController reloadFeederWithStartQueueIndex:] + 121
16 MediaPlayer 0x0000c511 -[MPMoviePlayerControllerNew _prepareToPlayWithStartIndex:] + 325
17 MediaPlayer 0x0000acad -[MPMoviePlayerControllerNew prepareToPlay] + 29
18 MediaPlayer 0x00009617 -[MPMoviePlayerControllerNew _movieSourceTypeAvailableNotification:] + 191
19 Foundation 0x00018fb7 _nsnote_callback + 143
20 CoreFoundation 0x00069e73 __CFXNotificationPost_old + 403
21 CoreFoundation 0x0001a37b _CFXNotificationPostNotification + 119
22 Foundation 0x000040c3 -[NSNotificationCenter postNotificationName:object:userInfo:] + 71
23 Foundation 0x0000c459 -[NSNotificationCenter postNotificationName:object:] + 25
24 MediaPlayer 0x0006e0a5 -[MPMovie _fileValidationDidFinishNotification:] + 193
25 Foundation 0x00018fb7 _nsnote_callback + 143
26 CoreFoundation 0x00069e73 __CFXNotificationPost_old + 403
27 CoreFoundation 0x0001a37b _CFXNotificationPostNotification + 119
28 Foundation 0x0000ba8f -[NSNotificationCenter postNotification:] + 139
29 Celestial 0x00014719 -[AVFileValidator postNotificationForCallback:] + 65
30 CoreFoundation 0x000277ff -[NSObject(NSObject) performSelector:withObject:] + 23
31 Celestial 0x000094a5 -[AVObjectRegistry safeInvokeWithDescription:] + 125
32 CoreFoundation 0x000277ff -[NSObject(NSObject) performSelector:withObject:] + 23
33 Foundation 0x00090bbd __NSThreadPerformPerform + 269
34 CoreFoundation 0x00071a8d __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 13
35 CoreFoundation 0x0007376f __CFRunLoopDoSources0 + 383
36 CoreFoundation 0x0007450b __CFRunLoopRun + 231
37 CoreFoundation 0x0001d8eb CFRunLoopRunSpecific + 231
38 CoreFoundation 0x0001d7f3 CFRunLoopRunInMode + 59
39 GraphicsServices 0x000036ef GSEventRunModal + 115
40 GraphicsServices 0x0000379b GSEventRun + 63
41 UIKit 0x000062a7 -[UIApplication _run] + 403
42 UIKit 0x00004e17 UIApplicationMain + 671
43 App 0x000031c3 0x1000 + 8643
Actually, such code for video thumbnail generation should be executed on the main thread.
This is NOT related to iOS 4.0.1 whatsoever.
Even under a NSOperation, you can execute the thumbnail generation through a performSelectorOnMainThread
and you should be fine.
User contributions licensed under CC BY-SA 3.0