[iPhone] Crash when user dismisses AVPlayerViewController from fullscreen mode.

Originator:fbartho
Number:rdar://29919046 Date Originated:08-Jan-2017 12:25 PM
Status:Open Resolved:
Product:iOS+SDK Product Version:iOS 9/iOS 10
Classification:Crash Reproducible:
 
Summary:
Our app recently started using HLS streams to deliver some tutorial / on boarding videos. These were simply presented as a nested AVPlayerViewController using normal UIViewController containment.

Since then, we have started receiving crash reports from the wild indicating that when the user uses the built-in full-screen presentation button, and then dismisses the fullscreen video, occasionally, the app will crash, and present to us information about UIViewControllerHierarchyInconsistency that comes from *private* childviewcontrollers of AVPlayerViewController (AVFullScreenPlaybackControlsViewController and AVFullScreenViewController)

Since this involves private classes, consuming code can't fix the issue.

Steps to Reproduce:
1. Create an AVPlayerViewController
2. Assign a simple HLS Stream (wrapped in an AVPlayerItem)
3. Configure it to not allow picture-in-picture and not updatesNowPlayingInfoCenter
4. Present AVPlayerView as a childViewController using addChildViewController
5. Either autoplay or user taps to play video
6. User taps the standard playback control to toggle the video into fullscreen
7. User Taps to dismiss from fullscreen

Expected Results:
User should be able to tap to present fullscreen & dismiss, indefinitely, without ever seeing a crash.

Actual Results:
(rarely) the app crashes with unhandled UIViewControllerHierarchyInconsistency exception which states an inconsistency between internal UIViewControllers that are part of AVPlayerViewController

-- See attached log for exact callstack, & unhandled exception line.

Version:
- 6% iOS 9.? (I can dig deeper if necessary)
- 4% iOS 10.0.2
- 7% iOS 10.1.1
- 94% iOS 10.2.0

I suspect this just reflects our current user distribution.

Notes:


Configuration:
Our crash reports from the wild document that this affects all iPhone-class devices that we currently see. It does not appear to affect iPads.

- 14% iPhone 6
- 23% iPhone 6S
- 15% iPhone 7
(remainder is other iPhone devices)

Attachments:
============= Begin 'AVPlayerViewController_FullScreen_Crash.log' =============
Fatal Exception: UIViewControllerHierarchyInconsistency
child view controller:<AVFullScreenPlaybackControlsViewController: 0x15f104c00> should have parent view controller:<AVPlayerViewController: 0x15f0cf800> but actual parent is:<AVFullScreenViewController: 0x15e5c5080>
 Raw Text

0	CoreFoundation	__exceptionPreprocess
1	libobjc.A.dylib	objc_exception_throw
2	CoreFoundation	-[NSException initWithCoder:]
3	UIKit	-[UIView(Hierarchy) _associatedViewControllerForwardsAppearanceCallbacks:performHierarchyCheck:isRoot:]
4	UIKit	-[UIView(Hierarchy) _willMoveToWindow:withAncestorView:]
5	UIKit	-[UIView(Internal) _addSubview:positioned:relativeTo:]
6	AVKit	-[AVPlayerViewController _updatePlaybackControlsViewController]
7	AVKit	-[AVPlayerViewController observeValueForKeyPath:ofObject:change:context:]
8	Foundation	-[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:]
9	Foundation	NSKeyValueNotifyObserver
10	Foundation	NSKeyValueDidChange
11	Foundation	-[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:]
12	AVKit	-[AVPlayerView _updateViewWindowState]
13	AVKit	-[AVPlayerView setFrame:]
14	UIKit	-[UIView(Geometry) _applyAutoresizingMaskWithOldSuperviewSize:]
15	CoreFoundation	__53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke
16	CoreFoundation	-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]
17	UIKit	-[UIView(Geometry) resizeSubviewsWithOldSize:]
18	UIKit	-[UIView(Geometry) setFrame:]
19	UIKit	-[UIViewController window:statusBarWillChangeFromHeight:toHeight:windowSizedViewController:]
20	UIKit	-[UIViewController window:statusBarWillChangeFromHeight:toHeight:]
21	UIKit	-[UIWindow handleStatusBarChangeFromHeight:toHeight:]
22	UIKit	+[UIWindow _noteStatusBarHeightChanged:oldHeight:forAutolayoutRootViewsOnly:]
23	UIKit	__79-[UIApplication _setStatusBarHidden:animationParameters:changeApplicationFlag:]_block_invoke
24	UIKit	+[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:]
25	UIKit	+[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:completion:]
26	UIKit	-[UIApplication _setStatusBarHidden:animationParameters:changeApplicationFlag:]
27	UIKit	-[UIApplication _updateCurrentStatusBarViewControllerAppearance]
28	UIKit	-[UIViewController setNeedsStatusBarAppearanceUpdate]
29	UIKit	-[UIViewController setNeedsStatusBarAppearanceUpdate]
30	UIKit	-[UIViewController _setPresentedStatusBarViewController:]
31	UIKit	-[UIViewController _presentViewController:modalSourceViewController:presentationController:animationController:interactionController:completion:]
32	UIKit	-[UIViewController _presentViewController:withAnimationController:completion:]
33	UIKit	-[UIViewController _performCoordinatedPresentOrDismiss:animated:]
34	UIKit	-[UIViewController presentViewController:animated:completion:]
35	AVKit	-[AVPlayerViewController _transitionToFullScreenViewControllerAnimated:completionHandler:]
36	AVKit	-[AVPlayerViewController(AVPlaybackControlsViewControllerActions) fullScreenButtonTapped:]
37	AVKit	-[AVPlaybackControlsViewController fullScreenButtonTapped:]
38	UIKit	-[UIApplication sendAction:to:from:forEvent:]
39	UIKit	-[UIControl sendAction:to:forEvent:]
40	UIKit	-[UIControl _sendActionsForEvents:withEvent:]
41	UIKit	-[UIControl touchesEnded:withEvent:]
42	UIKit	-[UIWindow _sendTouchesForEvent:]
43	UIKit	-[UIWindow sendEvent:]
44	UIKit	-[UIApplication sendEvent:]
45	UIKit	_UIApplicationHandleEventQueue
46	CoreFoundation	__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
47	CoreFoundation	__CFRunLoopDoSources0
48	CoreFoundation	__CFRunLoopRun
49	CoreFoundation	CFRunLoopRunSpecific
50	GraphicsServices	GSEventRunModal
51UIKit	UIApplicationMain
52	[redacted]	main.m line 17	main
53	libdispatch.dylib	(Missing)
============= End 'AVPlayerViewController_FullScreen_Crash.log' =============

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!