SRGSSR / pillarbox-apple

A next-generation reactive media playback ecosystem for Apple platforms.
https://testflight.apple.com/join/TS6ngLqf
MIT License
47 stars 7 forks source link

Startup time #911

Open defagos opened 2 weeks ago

defagos commented 2 weeks ago

As a player developer I want to understand how fast content starts so that we can find ways to improve the user experience if needed.

Acceptance criteria

Hints

Tasks

defagos commented 1 week ago

We can likely have a quite simple implementation which observes only AVPlayerItem changes:

  1. When an item is becomes the current one it starts in a loading state (loading URL). Save this initial time.
  2. When the item is replaced with an item having a playable URL, measure the time. The difference with the initial time describes how much time was required to fetch metadata.
  3. When the item timebase rate notification is received (or maybe isPlaybackLikelyToKeepUp changes to `true, we still need to figure out which criterium is the best), measure the time. The distance with the previous measured time describes the time needed to prepare the content for playback (startup time).
  4. The sum of both times is the total startup time.

Note that in playlists both times will be reduced because of pre-loading. This means such times describe the perceived user experience, not the actual technical time required for complete startup (except in the case a single item is played). While there exists a way to extract the time required for metadata retrieval, there is no such way to extract the time required for AVPlayerItem startup, so I guess this is the most consistent way of defining these times.

defagos commented 1 week ago

I think it would be probably great to:

defagos commented 6 days ago

Another option is to have something similar to AVMetrics, that means an event publisher for all interesting timing events, instead of storing values in properties. Our PlayerItemTracker protocol could then be expanded with a method called when an event is received.

Events could possibly include loading(time:), loaded(time:), ready(time:), maybe similar events for stalls.

defagos commented 6 days ago

The event publisher approach seems interesting. It can also be later extended by adding native events produced by AVMetrics.