Demo of using AVPictureInPictureController with an AVSampleBufferDisplayLayer content source not working on tvOS or macOS

Overview

PiP Bug Demo

I believe there is an Apple-level framework issue when using AVPictureInPictureController with an AVSampleBufferDisplayLayer content source on macOS or tvOS

This bug manifests itself with the following consequence: It is not possible to start a PiP session on tvOS or macOS when using an AVSampleBufferDisplayLayer as a content source for AVPictureInPictureController.

Tested on following platforms:

macOS: 12.0.1 (21A559)
iOS: 15.1 (19B74)
tvOS: 15.1.1 (19J587)

Submitted to Apple as FB9751461


PLEASE NOTE: THIS CODE MUST BE RUN ON REAL DEVICES. SIMULATORS DO NOT SUPPORT THIS NEW PIP API


This project presents 3 apps, one for iOS, tvOS, and macOS - which are all setup to use Picture in Picture with AVSampleBufferDisplayLayer as the content source. This is new API available in iOS 15, tvOS 15, and macOS 12.

For iOS and tvOS I have added the Picture in Picture background mode in Signing and Capabilities (Info.plist entry). There doesn't seem to be an equivelent on macOS.

I have also set the AVAudioSession to .playback on iOS and tvOS which is required to support Picture in Picture. Again, there seems to be no equivelent on macOS but I could be wrong?

do {
    try AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback)
} catch {
    print("Setting category to AVAudioSessionCategoryPlayback failed.")
}

In the relevant apps' view controller code, the AVPictureInPictureController setup is as follows:

let contentSource = AVPictureInPictureController.ContentSource(sampleBufferDisplayLayer: videoProvider.bufferDisplayLayer, playbackDelegate: self)


pipController = AVPictureInPictureController(contentSource: contentSource)
pipController.delegate = self

On iOS, as soon as I instantiate AVPictureInPictureController(contentSource: contentSource) I am receiving delegate callbacks to the AVPictureInPictureSampleBufferPlaybackDelegate methods:

IOSViewController.pictureInPictureControllerTimeRangeForPlayback(_:)
IOSViewController.pictureInPictureControllerIsPlaybackPaused(_:)

which it seems necessary for the system to call in order to setup Picture in Picture playback.

However, these methods ARE NEVER CALLED on tvOS or macOS

As a result, pipController.isPictureInPicturePossible is true on iOS but is always false on tvOS and macOS.

I suspect that somewhere in the guts of the AVKit/AVFoundation framework, these delegate methods are not being queried on tvOS nor macOS and so PiP setup is never completed and it will always fail.

You might also like...
 MeCab Demo for iOS 15 and SPM
MeCab Demo for iOS 15 and SPM

MeCab Demo for iOS 15 and SPM Sample project for MeCab, a Japanese tokenizer/morphological analyzer. Updated for iOS 15 and SPM. Successor to landonep

Demo app for SwiftUI state management
Demo app for SwiftUI state management

StateObject vs ObservedObject Demo Demo app for SwiftUI state management Run the app and push 3 buttons to increase each counter. Toggle one of the to

Official demo app released by Apple to teach SwiftUI

Landmarks This repository contains a demo application that I developed while following Apple's SwiftUI tutorials. Cloning Clone the repository using c

 emoji-picker demo 🥰
emoji-picker demo 🥰

emoji-picker demo 🥰 External dependencies Dependencies are managed by Swift Package Manager. SnapKit - a DSL to make Auto Layout easy on both iOS and

Demo project for MOPCON2021

Nav This project is a demo for MOPCON 2021. The topic is SwiftUI Navigation Study. There are 3 ways to see how the code works, which demos different v

MeetingSample iOS demo workspace

MeetingSample iOS demo workspace

Demo Vapor TIL App

Demo Vapor TIL App

Demo For the IOS application development lecture

IOSLectureCIfilterDemo This is a demo for the CIFilter topic of the IOS Application development lecture. The following topics are included: apply a fi

 This is a demo project which contains the steps to create App with TunnelRay library
This is a demo project which contains the steps to create App with TunnelRay library

This is a demo project which contains the steps to create App with TunnelRay library Environment requirements: XCode: 13.1 Cocoapods: 1.11.2 Detai

Owner
Chad Etzel
Chad Etzel
This simple app helps to understand whether customer eligible or not to take a loan.

Loan Agent Description This simple app helps to understand whether customer eligible or not to take a loan. Simplifications Several compromises were n

Andrius 0 Oct 31, 2021
Working through Challenge: SwiftUI science fiction! 🖖🏻

Challenge: SwiftUI science fiction! ????

An Trinh 27 Sep 27, 2022
The demo app demonstrates a real-time application using FindSurface to search point clouds, which ARKit provides, for geometry shapes.

FindSurface-GUIDemo-iOS (Swift) CurvSurf FindSurface™ GUIDemo for iOS (Swift) Overview This demo app demonstrates a real-time application using FindSu

CurvSurf 0 Nov 28, 2022
A demo project using VIPER architecture and building user interface programmatically

ProductDiscovery A demo project that building a UIKit user interface programmatically. Because the UI is made of code very long so I have separated it

Vinh Vo 7 Oct 1, 2021
Demo project using React Native technology to create a simple iOS app to find music in iTunes

React Native, native iOS apps with JavaScript iTunesCatalog is a demo app that aims to show the React Native platform potential. There are included th

Alexis Santos Pérez 55 Feb 10, 2022
ITunesSearchApiDemo - A demo for using iTunes Search API

iTunesSearchApiDemo This is a demo for using iTunes Search API. For more informa

Gokhan Mutlu 0 Jan 26, 2022
OMDburner is a free and Open Source Application developed using Swift.

OMDburner is a free and Open Source Application developed using Swift.

Ayush Singh 4 Oct 19, 2021
Demo of a simple ASP.NET Core web API written in Swift

Welcome! This repo is a demo which shows the use of Llama Swift with ASP.NET Core. Llama is my exploratory project to compile "other languages" for .N

Eric Sink 14 Mar 2, 2022
GoodAsOldPhones is the demo app of Swift tutorial on code school.

GoodAsOldPhones GoodAsOldPhones is the demo app of Swift tutorial on code school. This app demonstates basic use and implementation of tab bar control

Kushal Shingote 5 May 24, 2022