Strange crashes when using MPMoviePlayerController in iPad and iPad simulator with iOS 4.2.

Posted by Dave L on Stack Overflow See other posts from Stack Overflow or by Dave L
Published on 2011-03-05T04:54:34Z Indexed on 2011/03/05 15:25 UTC
Read the original article Hit count: 676

I'm getting crashes when trying to play a movie using MPMoviePlayerController on the iPad and in the iPad simulator using iOS 4.2. I am building using xcode 3.2.5 and the 4.2 SDK. When running on an iPad using iOS 3.2 or in the iPad simulator 3.2, the same code works fine, but on an iPad running 4.2 or in the iPad simulator 4.2, it crashes. The crash is due to an exception for calling an unknown selector down somewhere deep in the cocoa libraries, something tries to call a selector called "setHitRectInsets:" on a UIButton object. Also, the crash happens after control has returned to the main event loop. Anybody have any idea what might be causing this? Here is the code (roughly, some extraneous stuff deleted that doesn't seem to have any effect) that is crashing:

NSString *fullMovieFilename = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"m4v"];
NSURL *movieURL = [NSURL fileURLWithPath:fullMovieFilename];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
moviePlayer.controlStyle = MPMovieControlStyleNone;  // crash happens regardless of the setting here
[moviePlayer.view setFrame:self.view.bounds];
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES]; // crash happens whether i use fullscreen or not
[moviePlayer play];

The same code also works just find if I build using Xcode 3.2.3 and the 4.0 SDK. The crash stack trace looks like this:

2011-03-04 23:08:22.017 MyApp[31610:207] -[UIButton setHitRectInsets:]: unrecognized selector sent to instance 0x990bc60
2011-03-04 23:08:22.020 MyApp[31610:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton setHitRectInsets:]: unrecognized selector sent to instance 0x990bc60'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0151abe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0166f5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x0151c6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
    3   CoreFoundation                      0x0148c366 ___forwarding___ + 966
    4   CoreFoundation                      0x0148bf22 _CF_forwarding_prep_0 + 50
    5   MediaPlayer                         0x011b5bdb -[MPTransportControls createButtonForPart:] + 380
    6   MediaPlayer                         0x011b65d5 -[MPTransportControls _updateAdditions:removals:forPart:] + 110
    7   MediaPlayer                         0x011b4d78 -[MPTransportControls _reloadViewWithAnimation:] + 299
    8   MediaPlayer                         0x011b621a -[MPTransportControls setVisibleParts:] + 49
    9   MediaPlayer                         0x011b6e4a -[MPTransportControls initWithFrame:] + 173
    10  MediaPlayer                         0x011f9188 -[MPInlineTransportControls initWithFrame:] + 78
    11  MediaPlayer                         0x011f193a -[MPInlineVideoOverlay layoutSubviews] + 158
    12  QuartzCore                          0x00d6e451 -[CALayer layoutSublayers] + 181
    13  QuartzCore                          0x00d6e17c CALayerLayoutIfNeeded + 220
    14  QuartzCore                          0x00d6e088 -[CALayer layoutIfNeeded] + 111
    15  MediaPlayer                         0x011f130c -[MPInlineVideoOverlay setAllowsWirelessPlayback:] + 46
    16  MediaPlayer                         0x011f5b0d -[MPInlineVideoViewController _overlayView] + 526
    17  MediaPlayer                         0x011f6359 -[MPInlineVideoViewController _layoutForItemTypeAvailable] + 1350
    18  Foundation                          0x000e56c1 _nsnote_callback + 145
    19  CoreFoundation                      0x014f2f99 __CFXNotificationPost_old + 745
    20  CoreFoundation                      0x0147233a _CFXNotificationPostNotification + 186
    21  Foundation                          0x000db266 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
    22  Foundation                          0x000e75a9 -[NSNotificationCenter postNotificationName:object:] + 56
    23  MediaPlayer                         0x01184dd6 -[MPAVItem _updateForNaturalSizeChange] + 278
    24  MediaPlayer                         0x011818e4 __-[MPAVItem blockForDirectAVControllerNotificationReferencingItem:]_block_invoke_1 + 82
    25  MediaPlayer                         0x011899ba -[MPAVController _postMPAVControllerSizeDidChangeNotificationWithItem:] + 138
    26  Foundation                          0x000e56c1 _nsnote_callback + 145
    27  CoreFoundation                      0x014f2f99 __CFXNotificationPost_old + 745
    28  CoreFoundation                      0x0147233a _CFXNotificationPostNotification + 186
    29  Foundation                          0x000db266 -[NSNotificationCenter postNotificationName:object:userInfo:] + 134
    30  Celestial                           0x052a35b2 -[NSObject(NSObject_AVShared) postNotificationWithDescription:] + 176
    31  Celestial                           0x052ab214 -[AVController fpItemNotification:sender:] + 735
    32  Celestial                           0x052b5305 -[AVPlaybackItem fpItemNotificationInfo:] + 640
    33  Celestial                           0x052a3d5c -[AVObjectRegistry safeInvokeWithDescription:] + 211
    34  Foundation                          0x000fa9a6 __NSThreadPerformPerform + 251
    35  CoreFoundation                      0x014fc01f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    36  CoreFoundation                      0x0145a28b __CFRunLoopDoSources0 + 571
    37  CoreFoundation                      0x01459786 __CFRunLoopRun + 470
    38  CoreFoundation                      0x01459240 CFRunLoopRunSpecific + 208
    39  CoreFoundation                      0x01459161 CFRunLoopRunInMode + 97
    40  GraphicsServices                    0x01e4f268 GSEventRunModal + 217
    41  GraphicsServices                    0x01e4f32d GSEventRun + 115
    42  UIKit                               0x0038a42e UIApplicationMain + 1160
    43  MyApp                               0x0000837a main + 102
    44  MpApp                               0x00002009 start + 53
)
terminate called after throwing an instance of 'NSException'

Been fighting with this for several days, and have searched the internet quite a bit for anybody having similar problems, all with no luck. Any suggestions would be greatly appreciated.

© Stack Overflow or respective owner

Related posts about ipad

Related posts about mpmovieplayercontroller