Open defagos opened 5 months ago
Gave a shot at the implementation for fun on 925/avmetrics
. Made very significant progress:
compiler
preprocessor directive. The swift
version is namely either 5.10 or 6.0 depending on which version of Swift is adopted.The single subscriber issue is not related to the AVMetrics
API, rather to a known limitation of AsyncStream
s.
This issue also affects different streams matching different event types. Only one stream will deliver events, at random if Task
s are started at the same time.
For this reason I think that:
allMetrics()
stream contains a lot of noise.AVPlayerItem
since this requires an associated object and we might run into similar issues as we had with KVO-publishers retaining the observed object).To avoid issues with marking APIs as available on iOS / tvOS 18+ I would suggest the following:
AVMetricEvent
s externally. We always use our MetricEvent
s.Since AVMetrics
APIs are limited anyway because AsyncStream
s can only be consumed once this provides what we expect nicely without making our API unnecessarily complex. Of course AVMetricEvent
information is sometimes a bit richer but usually we are interested by a few pieces of information only anyway.
Current state as of beta 5:
AVMetrics
async sequence cannot be shared but some others like URL.lines
can. Not sure if this will change in upcoming betas.po
-ing the event but is likely not parsed at the moment. Hopefully this will be the case in upcoming betas, otherwise integration of AVMetrics
won't be that much useful in the end. The player time and the event date are filled, though (and correct, e.g. if starting playback at some position).Timings from content key metric events still zero on iOS 18 beta 6 😭
Still missing with iOS 18 beta 7.
Radar Missing timing metrics in AVMetricEvent
s, in particular AVMetricContentKeyRequestEvent
filed under FB14875223.
Still missing with iOS 18 beta 8.
I received feedback for FB14875223. This is expected behavior according to Apple, after all there is no URLSession
which is officially associated with a AVContentKeySessionDelegate
(we introduce our own). From a design perspective I still think that the AVMetrics
API is misleading, though.
The recommended approach to obtain metrics is to access the URLSession
we use and access its NSURLSessionTaskMetrics
. If we really want to extract DRM timings I therefore see three options:
ContentKeySessionDelegate
which we can somehow report timings to the caller. Maybe we have to inject the URLSession
or something to return metrics with (e.g. a publisher). But this makes our implementation less universal than it way (we currently support any AVContentKeySessionDelegate
).
As a Pillarbox developer I want to benefit from new APIs introduced in iOS and tvOS 18 to better understand the behavior of Pillarbox.
Remarks
timeSpentInInitialStartup
provided inAVMetricPlayerItemPlaybackSummaryEvent
matchestimeTaken
fromAVMetricPlayerItemInitialLikelyToKeepUpEvent
. These values are smaller than the values we get when measuring the total startup time according to recommendations provided at WWDC. It is also the same value as provided by the first eventstartupTime
in the access log.Hints
AVMetrics
are missing in iOS 18 beta 1.AVMetricContentKeyRequestEvent
provides the key system used to load the content. It can be compared toclearKey
,authorizationToken
orfairPlayStreaming
to find its type, letting us guess which timing we need to provide. Note that our token-protected streams are currently reported as usingclearKey
.Acceptance criteria
AVPlayer
metrics are provided in Pillarbox player metric events.Tasks
AVMetrics
events.AVMetricEvent
to be collected even if not needed, though). Or we could just collect some essential events and discard less relevant ones, at least for tracker implementation purposes.