Closed defagos closed 1 day ago
As described in AVFoundation legacy documentation, media playback is actually performed by an out-of-process daemon:
In iOS and tvOS, the situation can be even more serious because media operations are performed by the shared media services daemon
This daemon is mediaplaybackd
and its activity can be investigated with Instruments Activity Monitor instrument (Instrument might take quite a while before starting a session, be patient). There are other interesting media
-related daemons like mediaparserd
which, I guess, handles HLS playlist parsing:
We can check what happens with the simple following code which makes it possible to interactively add players loaded with the same content:
import AVFoundation
import SwiftUI
struct ContentView: View {
@State private var players: [AVPlayer] = []
var body: some View {
Button(action: addPlayer) {
Text("Add player")
}
}
private func addPlayer() {
players.append(.init(
url: URL(string: "...")!)
)
}
}
#Preview {
ContentView()
}
and the following procedure:
I repeated the procedure with two different HLS streams, Bip Bop and the trailer for episode 1 of the Morning Show. Each series of screenshots shows the status reached after having loaded 0 to 4 players.
mediaplaybackd
memory usage.
As a developer using Pillarbox, and as a Pillarbox developer as well, I would like to better understand resources required by media playback so that I can make a better use of them in contexts where several player instances are needed.
Acceptance criteria
Tasks