AVPlayerLayer doesn't always show video after using AVVideoCompositionCoreAnimationTool, but audio still plays

Originator:sami
Number:rdar://28553945 Date Originated:2016-09-29
Status:Resolved Resolved:
Product:iOS SDK Product Version:10.0
Classification:Serious Bug Reproducible:Sometimes
 
Summary:
After exporting a video using AVAssetExportSession and AVVideoCompositionCoreAnimationTool to composite a layer on top of the video during export, videos played using AVPlayerLayer fail to show video but audio plays so the player is playing (sometimes seeking spurs the video into action). This doesn't seem to be caused by hitting the AV encode/decode pipeline limit because it often happens after a single export, which as far as I know only spins up 2 pipelines: 1 for the AVAssetExportSession and another for the AVPlayer.

This seems to happen most frequently when the video is played within several seconds of the export. Once I see it happen if I try to play a video again without waiting for 20-30 seconds it often reoccurs the next time. It is sporadic though, if you do it over and over it sometimes works and sometimes does not. Overall it is pretty consistently reproducible.

Steps to Reproduce:
1. Export an AVAsset using AVVideoComposionCoreAnimationTool to overlay a CALayer on the video.

2. Show a video using AVPlayerLayer soon after the export completes.


Expected Results:
I expect the video to play, with video visible and audio audible, even when playing a video immediately after exporting an asset with the CA tool.


Actual Results:
The video does not appear, but the audio is audible so the player is playing. In the attached example project the player layer has a blue background so you can plainly see that it is set up correctly and visible, but no video shows up.

Version:
iOS 10.0.2 (14A456), iOS 10.1 (14B55c)

Notes:
I’ve worked around this issue by using a custom video compositor using CoreImage instead of the provided CA tool.

The attached project illustrates the problem on iOS 10 devices (not the simulator). Tapping the “Cause Trouble” button exports a video using AVVIdeoCompositionCoreAnimationTool and then plays a video in the middle of the screen when the export completes. The CAPlayerLayer and CAPlayer are reused as to not hit the AV encode/decode pipeline limit, and the layer has a blue background so it’s obvious when it is not showing video. You will want to turn the volume up a bit to hear the audio so you can confirm the player is playing the asset.

Configuration:
iPhone 6s, iPhone 6 Plus, iPhone 7 Plus

Attachments:
'AVPlayerLayerSoundOnlyBug_iOS10.zip' was successfully uploaded.

https://www.dropbox.com/s/5p384mogjzflvqk/AVPlayerLayerSoundOnlyBug_iOS10.zip?dl=0

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!