AVPlayerLayer sometimes doesn't render video in iOS 10

Hi,

I've been investigating an issue where AVPlayerLayer doesn't render the video(audio only) occasionally, but if you pause the video and wait for 5 sec then play again, the video comes back...

I'm debugging on on iPhone 5s with iOS 10.0.1 (14A403).

I implemented AVPlayer like this:


     AVPlayer *player = [AVPlayer playerWithURL:url];

     [player play];

     AVPlayerLayer *layer = [AVPlayerLayer layer];

     layer.player = player;

     layer.frame = CGRectMake(0, 0, 300, 300);

     [self.view.layer addSublayer:layer];


And the issue NEVER HAPPEDNS on iOS 10 simulator and the same code also works fine on iOS 9 (both device and simulator).

Does anyone know if there is any other change in iOS 10 that I need to make?

Thanks in advance.

Replies

Faced the same problem!

I still can't figure out the solution, but the avplayer issue must have something to do with "exportAsynchronouslyWithCompletionHandler", if I play video without calling exportAsynchronouslyWithCompletionHandler before, everthing is fine. But if I export a video with exportAsynchronouslyWithCompletionHandler then play that video, it has chance to play without video frames...


I also notice that when the problem occur, videos inside my camera roll also can't play normally within iPhone built-in Photos App...

Hello YitingLin,


Did you resolve this issue? I have encountered a similar problem.


I can confirm that the AVPlayerLayer has proper a legitimate frame dimensions. I did this by setting a background color. When the frames are not rendered, the background color remains on the screen. What's odd is that AVPlayerLayer isReadyForDisplay returns true when the video frame isn't displayed. The audio always plays though.


Thanks

Krishna

Hello Krishna,


I have reported this issue to Apple and still waiting for their response. I built a simple project to reproduce the problem, and I found that AVVideoCompositionCoreAnimationTool is the cause of the issue. If I remove all the code related to AVVideoCompositionCoreAnimationTool, the problem no longer exists.


I will update you once I get more updates.

Yiting

Came across the same problem and I did also use the `AVVideoCompositionCoreAnimationTool`. Maybe this is the root cause. Hope your update!

Im facing the same problem and is related to exportAsynchronouslyWithCompletionHandler which is still active once you want to play a video with avplayer. Were you able to find a solution? Im using exportAsynchronouslyWithCompletionHandler to watermark my video.

Same problem here, any news on this?

Same issue here are as well, although we aren't making any calls to exportAsynchronouslyWithCompletionHandler, or AVVideoCompositionCoreAnimationTool. We've done all of the other troubleshooting as well to verify the size and position of the view/layer. Interestingly, we can force the video to display by rotating or touching the screen.

I'm having the same issue and I'm also using AVVideoCompositionCoreAnimationTool. Remove that code in my app fixes the issues.


Has anyone managed to find a workaround so far?

Faced the same problem!

It must be something wrong by using AVVideoCompositionCoreAnimationTool in iOS10.

Hope your update!

Hi wawatson,


have you solved the issue. I have the same issue.

We're having the exact same issue. Happens about half the time after calling exportAsynchronouslyWithCompletionHandler with AVVideoCompositionCoreAnimationTool. This is delaying our next release.

Have you found a solution?

Same problem. Have you found a solution?

iOS 10.2 seems fixed this issue by my testing. well done AAPL well done lol