Playback telemetry
This commit is contained in:
1 parent
6e964fa2e5
commit
332e1e7ef6
11 files changed
+1526
-195
No files matched your search
@@ -0,0 +1,355 @@
|
||||
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace PlaybackTelemetry
|
||||
|
||||
const PLAY_START_SAMPLE_CAP = 10
|
||||
const UNDERRUN_SAMPLE_CAP = 10
|
||||
const INV_D1_SAMPLE_CAP = 3
|
||||
|
||||
enum Outcome
|
||||
Closed = "closed"
|
||||
Finished = "finished"
|
||||
Error = "error"
|
||||
end enum
|
||||
|
||||
enum Span
|
||||
None = 0
|
||||
Playing = 1
|
||||
BufferingWithoutStatus = 2
|
||||
Underrun = 3
|
||||
NotUnderrun = 4
|
||||
end enum
|
||||
|
||||
function ContentBackend(content as object) as string
|
||||
if content <> invalid and not StringUtils.IsNullOrEmpty(content.backend)
|
||||
return content.backend
|
||||
end if
|
||||
return "unknown"
|
||||
end function
|
||||
|
||||
' The summary's wire rule: false, 0, "", [] and invalid are omitted, at every depth; a reader takes an absent
|
||||
' field as that default.
|
||||
function OmitDefaults(value as dynamic) as dynamic
|
||||
if IsAssociativeArray(value)
|
||||
result = {}
|
||||
for each key in value
|
||||
item = PlaybackTelemetry.OmitDefaults(value[key])
|
||||
if not PlaybackTelemetry.IsDefault(item)
|
||||
result[key] = item
|
||||
end if
|
||||
end for
|
||||
return result
|
||||
end if
|
||||
if IsArray(value)
|
||||
result = []
|
||||
for each item in value
|
||||
result.Push(PlaybackTelemetry.OmitDefaults(item))
|
||||
end for
|
||||
return result
|
||||
end if
|
||||
return value
|
||||
end function
|
||||
|
||||
function IsDefault(value as dynamic) as boolean
|
||||
if value = invalid
|
||||
return true
|
||||
end if
|
||||
if IsBool(value)
|
||||
return not value
|
||||
end if
|
||||
if IsNumber(value)
|
||||
return value = 0
|
||||
end if
|
||||
if IsString(value)
|
||||
return value = ""
|
||||
end if
|
||||
if IsArray(value)
|
||||
return value.Count() = 0
|
||||
end if
|
||||
return false
|
||||
end function
|
||||
|
||||
class Recorder
|
||||
private playerTimer as object = invalid ' started with the player: every *Ms is ms on it
|
||||
private transport as object = invalid
|
||||
private top as object = invalid
|
||||
|
||||
private outcome as string = PlaybackTelemetry.Outcome.Closed
|
||||
private metadataDoneAtMs as integer = -1
|
||||
private firstPlayingAtMs as integer = -1
|
||||
private playStartInfos as object = invalid
|
||||
private playStartCount as integer = 0
|
||||
private span as integer = PlaybackTelemetry.Span.None
|
||||
private spanStartMs as integer = 0
|
||||
private lastIsUnderrun as boolean = false
|
||||
private playingMs as integer = 0
|
||||
private underrunCount as integer = 0
|
||||
private underrunMs as integer = 0
|
||||
private underrunSamples as object = invalid
|
||||
private bufferingsWithoutStatusCount as integer = 0
|
||||
private isUnderrunChangeCount as integer = 0
|
||||
private errorCount as integer = 0
|
||||
private healCount as integer = 0
|
||||
private healSamples as object = invalid
|
||||
private tailResolveCount as integer = 0
|
||||
private tailResolveSamples as object = invalid
|
||||
|
||||
function new(deps as object)
|
||||
m.playerTimer = deps.playerTimer
|
||||
m.transport = deps.transport
|
||||
m.top = deps.top
|
||||
m.playStartInfos = []
|
||||
m.underrunSamples = []
|
||||
m.healSamples = []
|
||||
m.tailResolveSamples = []
|
||||
end function
|
||||
|
||||
function OnMetadataDone() as void
|
||||
m.metadataDoneAtMs = m.playerTimer.TotalMilliseconds()
|
||||
end function
|
||||
|
||||
function OnState(state as string) as void
|
||||
nowMs = m.playerTimer.TotalMilliseconds()
|
||||
m.CloseSpan(nowMs, state)
|
||||
m.spanStartMs = nowMs
|
||||
if state = VideoState.Playing
|
||||
m.span = PlaybackTelemetry.Span.Playing
|
||||
if m.firstPlayingAtMs < 0
|
||||
m.firstPlayingAtMs = nowMs
|
||||
end if
|
||||
' playing under an error dialog: the playback recovered, so the error did not end it.
|
||||
if m.outcome = PlaybackTelemetry.Outcome.Error
|
||||
m.outcome = PlaybackTelemetry.Outcome.Closed
|
||||
end if
|
||||
else if state = VideoState.Buffering
|
||||
m.span = PlaybackTelemetry.Span.BufferingWithoutStatus
|
||||
else
|
||||
m.span = PlaybackTelemetry.Span.None
|
||||
end if
|
||||
end function
|
||||
|
||||
' Measured: a seek, resume, startup or retry buffering reports isUnderrun false; only a playback that ran
|
||||
' dry reports true.
|
||||
function OnBufferingStatus(status as object) as void
|
||||
if status = invalid or not IsBool(status.isUnderrun)
|
||||
return
|
||||
end if
|
||||
isUnderrun = status.isUnderrun
|
||||
if m.span = PlaybackTelemetry.Span.BufferingWithoutStatus
|
||||
if isUnderrun
|
||||
m.span = PlaybackTelemetry.Span.Underrun
|
||||
else
|
||||
m.span = PlaybackTelemetry.Span.NotUnderrun
|
||||
end if
|
||||
m.lastIsUnderrun = isUnderrun
|
||||
else if (m.span = PlaybackTelemetry.Span.Underrun or m.span = PlaybackTelemetry.Span.NotUnderrun) and isUnderrun <> m.lastIsUnderrun
|
||||
m.isUnderrunChangeCount += 1
|
||||
m.lastIsUnderrun = isUnderrun
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnPlayStartInfo(info as object) as void
|
||||
if info = invalid
|
||||
return
|
||||
end if
|
||||
m.playStartCount += 1
|
||||
if m.playStartInfos.Count() < PlaybackTelemetry.PLAY_START_SAMPLE_CAP
|
||||
m.playStartInfos.Push(info)
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnErrorDialog() as void
|
||||
m.outcome = PlaybackTelemetry.Outcome.Error
|
||||
end function
|
||||
|
||||
function OnFinished() as void
|
||||
m.outcome = PlaybackTelemetry.Outcome.Finished
|
||||
end function
|
||||
|
||||
function RecordHeal(source as string) as void
|
||||
m.healCount += 1
|
||||
positionMs = Int(m.top.position * 1000)
|
||||
floorMs = m.transport.SafetyFloorMs()
|
||||
LogDebug(`INV-D1 heal: re-pause under active transport. src=${source} mode=${m.transport.transportMode} isLive=${m.transport.isLive} state=${m.top.state} posMs=${positionMs} cursorMs=${m.transport.cursorMs} edgeMs=${m.transport.edgeMs} floorMs=${floorMs} heal=${m.healCount}`)
|
||||
if m.healSamples.Count() < PlaybackTelemetry.INV_D1_SAMPLE_CAP
|
||||
m.healSamples.Push({
|
||||
"at_ms": m.playerTimer.TotalMilliseconds()
|
||||
"source": source
|
||||
"mode": m.transport.transportMode
|
||||
"position_ms": positionMs
|
||||
"cursor_ms": m.transport.cursorMs
|
||||
"edge_ms": m.transport.edgeMs
|
||||
"floor_ms": floorMs ' -1 = no floor: VOD, or a live stream with an unknown window
|
||||
})
|
||||
end if
|
||||
end function
|
||||
|
||||
function RecordTailResolve(source as string) as void
|
||||
m.tailResolveCount += 1
|
||||
positionMs = Int(m.top.position * 1000)
|
||||
floorMs = m.transport.SafetyFloorMs()
|
||||
LogDebug(`INV-D1 tail-resolve: resume forward. src=${source} posMs=${positionMs} cursorMs=${m.transport.cursorMs} floorMs=${floorMs} edgeMs=${m.transport.edgeMs} resolve=${m.tailResolveCount}`)
|
||||
if m.tailResolveSamples.Count() < PlaybackTelemetry.INV_D1_SAMPLE_CAP
|
||||
m.tailResolveSamples.Push({
|
||||
"at_ms": m.playerTimer.TotalMilliseconds()
|
||||
"source": source
|
||||
"position_ms": positionMs
|
||||
"cursor_ms": m.transport.cursorMs
|
||||
"floor_ms": floorMs
|
||||
"edge_ms": m.transport.edgeMs
|
||||
})
|
||||
end if
|
||||
end function
|
||||
|
||||
function ReportVideoError(errorData as object, errorInfo as object, url as dynamic, urlIndex as dynamic, shownInDialog as boolean) as void
|
||||
m.errorCount += 1
|
||||
' malformed data: the last generated DASH/HLS manifest and player response diagnose it from the report.
|
||||
attachments = invalid
|
||||
if errorData.body.Instr("malformed data") <> -1 or errorData.body.Instr("invalid pathname") <> -1
|
||||
attachments = [{
|
||||
filename: "last_generated_dash.xml"
|
||||
content_type: "plain/text"
|
||||
data: ValidString(ReadAsciiFile("cachefs:/last_generated_dash.xml"))
|
||||
}, {
|
||||
filename: "last_generated_hls.m3u8"
|
||||
content_type: "plain/text"
|
||||
data: ValidString(ReadAsciiFile("cachefs:/last_generated_hls.m3u8"))
|
||||
}, {
|
||||
filename: "last_player_response.json"
|
||||
content_type: "application/json"
|
||||
data: ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
||||
}]
|
||||
end if
|
||||
potAttached = false
|
||||
potSource = "none"
|
||||
loggedIn = false
|
||||
urls = invalid
|
||||
content = m.top.content
|
||||
if content <> invalid
|
||||
urls = content.playletStreamUrls
|
||||
potAttached = ValidBool(content.potAttached)
|
||||
loggedIn = ValidBool(content.loggedIn)
|
||||
if not StringUtils.IsNullOrEmpty(content.potSource)
|
||||
potSource = content.potSource
|
||||
end if
|
||||
end if
|
||||
backend = PlaybackTelemetry.ContentBackend(content)
|
||||
isLive = m.transport.isLive
|
||||
message = [
|
||||
errorData.title
|
||||
errorData.body
|
||||
`Dialog shown: ${shownInDialog}`
|
||||
`Position: ${m.top.position}`
|
||||
`Duration: ${m.top.duration}`
|
||||
`Url: ${url}`
|
||||
"Urls: " + FormatJson(urls)
|
||||
`Url index: ${urlIndex}`
|
||||
`pot_attached: ${potAttached}`
|
||||
`pot_source: ${potSource}`
|
||||
`logged_in: ${loggedIn}`
|
||||
`backend: ${backend}`
|
||||
`is_live: ${isLive}`
|
||||
].Join(Chr(10))
|
||||
fingerprint = [
|
||||
Locale.VideoPlayer.ErrorPlayingVideo
|
||||
m.top.errorMsg
|
||||
m.top.errorCode
|
||||
]
|
||||
if errorInfo <> invalid
|
||||
fingerprint.Append([
|
||||
errorInfo.source
|
||||
errorInfo.ignored
|
||||
errorInfo.category
|
||||
errorInfo.errcode
|
||||
errorInfo.drmerrcode
|
||||
])
|
||||
end if
|
||||
fingerprint.Append([shownInDialog, potAttached, potSource, loggedIn, backend, isLive])
|
||||
if shownInDialog
|
||||
level = "error"
|
||||
else
|
||||
level = "warning"
|
||||
end if
|
||||
LogTelemetryEvent({
|
||||
level: level
|
||||
message: message
|
||||
fingerprint: fingerprint
|
||||
attachments: attachments
|
||||
})
|
||||
end function
|
||||
|
||||
function ReportContentJobFailure(error as dynamic) as void
|
||||
LogError(`VideoContentJob FAILED: ${error}\nbackend: ${PlaybackTelemetry.ContentBackend(m.top.content)}`)
|
||||
end function
|
||||
|
||||
function ReportStopFailure(error as object) as void
|
||||
LogError("error stopping video:", ErrorUtils.Format(error))
|
||||
end function
|
||||
|
||||
function SendSummary() as void
|
||||
lifetimeMs = m.playerTimer.TotalMilliseconds()
|
||||
endedInUnderrun = m.span = PlaybackTelemetry.Span.Underrun
|
||||
m.CloseSpan(lifetimeMs, "")
|
||||
m.span = PlaybackTelemetry.Span.None
|
||||
content = m.top.content
|
||||
summary = {
|
||||
"live": m.transport.isLive
|
||||
"backend": PlaybackTelemetry.ContentBackend(content)
|
||||
"outcome": m.outcome
|
||||
"metadata_done_at_ms": m.metadataDoneAtMs
|
||||
"first_playing_at_ms": m.firstPlayingAtMs
|
||||
"play_start_infos": m.playStartInfos
|
||||
"play_start_count": m.playStartCount
|
||||
"lifetime_ms": lifetimeMs
|
||||
"playing_ms": m.playingMs
|
||||
"underrun_count": m.underrunCount
|
||||
"underrun_ms": m.underrunMs
|
||||
"underrun_samples": m.underrunSamples
|
||||
"ended_in_underrun": endedInUnderrun
|
||||
"bufferings_without_status_count": m.bufferingsWithoutStatusCount
|
||||
"is_underrun_change_count": m.isUnderrunChangeCount
|
||||
"error_count": m.errorCount
|
||||
"heal_count": m.healCount
|
||||
"heal_samples": m.healSamples
|
||||
"tail_resolve_count": m.tailResolveCount
|
||||
"tail_resolve_samples": m.tailResolveSamples
|
||||
}
|
||||
if content <> invalid
|
||||
summary["stream_source"] = content.playletStreamSource
|
||||
summary["drm"] = not StringUtils.IsNullOrEmpty(ValidAssociativeArray(content.drmParams).keySystem)
|
||||
summary["stream_url_index"] = content.playletStreamUrlIndex
|
||||
if m.firstPlayingAtMs < 0 or m.underrunCount > 0 or m.bufferingsWithoutStatusCount > 0 or m.isUnderrunChangeCount > 0 or m.errorCount > 0 or m.healCount > 0 or m.outcome = PlaybackTelemetry.Outcome.Error
|
||||
summary["video_id"] = content.videoId
|
||||
end if
|
||||
end if
|
||||
LogTelemetryEvent({
|
||||
level: "info"
|
||||
message: FormatJson(PlaybackTelemetry.OmitDefaults(summary))
|
||||
fingerprint: ["playback summary"]
|
||||
})
|
||||
end function
|
||||
|
||||
' A buffering that got no status counts only when it reached playing: a close, pause or error can land before
|
||||
' the first status, which follows the buffering edge by up to ~65 ms (measured).
|
||||
function CloseSpan(nowMs as integer, nextState as string) as void
|
||||
durationMs = nowMs - m.spanStartMs
|
||||
if m.span = PlaybackTelemetry.Span.Playing
|
||||
m.playingMs += durationMs
|
||||
else if m.span = PlaybackTelemetry.Span.Underrun
|
||||
m.underrunCount += 1
|
||||
m.underrunMs += durationMs
|
||||
if m.underrunCount <= PlaybackTelemetry.UNDERRUN_SAMPLE_CAP
|
||||
m.underrunSamples.Push({ "at_ms": m.spanStartMs, "ms": durationMs })
|
||||
end if
|
||||
else if m.span = PlaybackTelemetry.Span.BufferingWithoutStatus and nextState = VideoState.Playing
|
||||
m.bufferingsWithoutStatusCount += 1
|
||||
end if
|
||||
end function
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -23,6 +23,9 @@ A thin coordinator over a pure-logic brain and projection-only renderers:
|
||||
nav, storyboard normalize).
|
||||
- **`SponsorBlockController.bs`** (class) / **`ErrorDialogController.bs`** (namespace functions) — SponsorBlock
|
||||
and error logic; the coordinator owns the node-scoped pieces (job callbacks, the dialog node).
|
||||
- **`PlaybackTelemetry.bs`** (class, `m.playbackTelemetry`) — every telemetry event the player sends: video error
|
||||
reports, and the playback summary sent on close (startup, play starts, playing and underrun time, errors, INV-D1
|
||||
heals and tail resolves, how it ended). The coordinator reports what happens; it holds no telemetry code.
|
||||
- **Renderers** (`TrickPlayBar/`, `BifDisplay/`, `LargePause/`, `LoadBufferSpinner/`, `ButtonRow/`,
|
||||
`VideoPlayerButton/`) — SceneGraph components that are pure projections of scalar input fields.
|
||||
Each self-derives its own visibility from `transportMode` (a commit sets `transportMode=idle` and the bif
|
||||
@@ -35,7 +38,7 @@ A thin coordinator over a pure-logic brain and projection-only renderers:
|
||||
|-------|-------|----------|
|
||||
| Unit — logic | `source/tests/VideoPlayerDev/*.spec.bs` | `npm run test:lib` |
|
||||
| Unit — renderers | `components/VideoPlayerDev/**/*.spec.bs` | `npm run test:lib` |
|
||||
| Seam (real coordinator, faked device) | `components/VideoPlayerDev/tests/VideoPlayerDevSeam.spec.bs` | `npm run test:lib` |
|
||||
| Seam (real coordinator, faked device) | `components/VideoPlayerDev/tests/*.spec.bs` | `npm run test:lib` |
|
||||
| Integration (on device) | `integration-tests/vpd-player-*.ts` | `npm run test:integration:player [-- filter]` |
|
||||
|
||||
The integration suite asserts `#VideoPlayer` is a `VideoPlayerDev`, so it only passes when the lib is built
|
||||
|
||||
@@ -5,12 +5,12 @@ import "pkg:/components/JobSystem/JobSystem.bs"
|
||||
import "pkg:/components/Services/Innertube/Constants.bs"
|
||||
import "pkg:/components/VideoPlayer/Lounge.bs"
|
||||
import "pkg:/components/VideoPlayerDev/ErrorDialogController.bs"
|
||||
import "pkg:/components/VideoPlayerDev/PlaybackTelemetry.bs"
|
||||
import "pkg:/components/VideoPlayerDev/PlayerCoordinatorLogic.bs"
|
||||
import "pkg:/components/VideoPlayerDev/SponsorBlockController.bs"
|
||||
import "pkg:/components/VideoPlayerDev/TransportController.bs"
|
||||
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
||||
import "pkg:/components/VideoQueue/VideoQueueUtils.bs"
|
||||
import "pkg:/source/utils/ErrorUtils.bs"
|
||||
import "pkg:/source/utils/Locale.bs"
|
||||
import "pkg:/source/utils/Logging.bs"
|
||||
import "pkg:/source/utils/MathUtils.bs"
|
||||
@@ -18,11 +18,6 @@ import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
' Per-content ceiling on INV-D1 heal / tail-resolve telemetry: a pathological loop otherwise emits one
|
||||
' error per second for as long as it runs. Occurrences keep counting past the cap (each message carries
|
||||
' its ordinal) and a capped heal loop's true total rides out in one summary event when the content ends.
|
||||
const INV_D1_TELEMETRY_CAP = 3
|
||||
|
||||
' Coordinator for the custom video player. extends Video, enableUI=false.
|
||||
'
|
||||
' Owns the focused Video node + key router, the Chrome-group fade, PiP resize, and lifecycle plumbing. All
|
||||
@@ -48,6 +43,11 @@ function Initialize()
|
||||
m.top.notificationInterval = 1
|
||||
|
||||
m.transport = new TransportController.Controller()
|
||||
m.playbackTelemetry = new PlaybackTelemetry.Recorder({
|
||||
playerTimer: CreateObject("roTimespan")
|
||||
transport: m.transport
|
||||
top: m.top
|
||||
})
|
||||
|
||||
m.videoContentJob = invalid
|
||||
m.sponsorBlockSegmentsJob = invalid
|
||||
@@ -60,8 +60,6 @@ function Initialize()
|
||||
m.errorDialogNode = invalid
|
||||
m.ignoreNextFinished = false ' a retry replay -> swallow the next "finished" edge
|
||||
m.videoPlayedSuccessfully = false ' true once the stream has actually played (gates error-retry)
|
||||
m.healCount = 0 ' INV-D1 heals this content (telemetry stops at INV_D1_TELEMETRY_CAP; total goes out in the close summary)
|
||||
m.tailResolveCount = 0 ' live tail resolutions this content (telemetry capped the same way)
|
||||
|
||||
m.chromeMode = ChromeMode.Hidden
|
||||
m.liveBadgeHoldActive = false ' the "● LIVE" reveal hold is running
|
||||
@@ -168,6 +166,8 @@ function OnNodeReady()
|
||||
m.top.ObserveField("thumbnailTiles", FuncName(OnThumbnailTiles))
|
||||
' an external resume/play (the linked phone via Lounge) under an active transport must take over.
|
||||
m.top.ObserveField("control", FuncName(OnControlChange))
|
||||
m.top.ObserveField("bufferingStatus", FuncName(OnBufferingStatus))
|
||||
m.top.ObserveField("playStartInfo", FuncName(OnPlayStartInfo))
|
||||
|
||||
' a player that starts minimized shows the PiP hint (1s after the shrink settles, auto-hides after 5s).
|
||||
m.showFullScreenHint = not m.container.fullscreen
|
||||
@@ -736,6 +736,7 @@ function OnVideoState(event as object) as void
|
||||
end if
|
||||
state = event.getData()
|
||||
LogInfo("videoState ->", state)
|
||||
m.playbackTelemetry.OnState(state)
|
||||
|
||||
' push the new state to the cast/lounge side in real time.
|
||||
Lounge.SendOnStateChange()
|
||||
@@ -784,6 +785,20 @@ function OnVideoState(event as object) as void
|
||||
end if
|
||||
end function
|
||||
|
||||
function OnBufferingStatus(event as object) as void
|
||||
if m.onCloseCalled = true
|
||||
return
|
||||
end if
|
||||
m.playbackTelemetry.OnBufferingStatus(event.getData())
|
||||
end function
|
||||
|
||||
function OnPlayStartInfo(event as object) as void
|
||||
if m.onCloseCalled = true
|
||||
return
|
||||
end if
|
||||
m.playbackTelemetry.OnPlayStartInfo(event.getData())
|
||||
end function
|
||||
|
||||
' A transport freezes the video; if the device is playing under an active transport (Roku resumes a paused
|
||||
' Video on a seek, or a freeze command was dropped), re-pause. The transport stays active so the bif stays
|
||||
' visible over the now-paused video. Called from OnVideoState (the change edge) and OnPosition (the net —
|
||||
@@ -797,33 +812,10 @@ function EnforceTransportFreeze(source as string) as void
|
||||
' the play-through seek that opened this transport has landed, so clear autoplayAfterSeek; a later
|
||||
' seek-complete must not silently un-freeze the video behind the transport.
|
||||
m.top.autoplayAfterSeek = false
|
||||
m.healCount += 1
|
||||
' Position detail rides in the message; the fingerprint pins grouping (heal + mode + trigger) so it
|
||||
' stays a handful of issues instead of fragmenting on the per-event posMs/cursorMs values.
|
||||
' floorMs=-1 marks an unknown-window live stream — the one shape the tail resolution cannot cover.
|
||||
healInfo = `INV-D1 heal: re-pause under active transport. src=${source} mode=${m.transport.transportMode} isLive=${m.transport.isLive} state=${m.top.state} posMs=${Int(m.top.position * 1000)} cursorMs=${m.transport.cursorMs} edgeMs=${m.transport.edgeMs} floorMs=${m.transport.SafetyFloorMs()} heal=${m.healCount}`
|
||||
LogErrorNoTelemetry(healInfo)
|
||||
if m.healCount <= INV_D1_TELEMETRY_CAP
|
||||
LogTelemetryEvent({
|
||||
level: "warning"
|
||||
message: healInfo
|
||||
fingerprint: ["INV-D1 heal", m.transport.transportMode, source]
|
||||
})
|
||||
end if
|
||||
m.playbackTelemetry.RecordHeal(source)
|
||||
else if action = PlayerCoordinatorLogic.SafetyAction.ResumeLiveTail
|
||||
' the tail overtook the frozen playhead: resolve forward (ResolveLiveTail), don't heal. Telemetered
|
||||
' at info level so the field shows the resolution working — resolve>1 on one content means the
|
||||
' resumed playhead was overtaken AGAIN, i.e. LIVE_TAIL_RESUME_MARGIN_MS is too small.
|
||||
m.tailResolveCount += 1
|
||||
resolveInfo = `INV-D1 tail-resolve: resume forward. src=${source} posMs=${Int(m.top.position * 1000)} cursorMs=${m.transport.cursorMs} floorMs=${m.transport.SafetyFloorMs()} edgeMs=${m.transport.edgeMs} resolve=${m.tailResolveCount}`
|
||||
LogInfo(resolveInfo)
|
||||
if m.tailResolveCount <= INV_D1_TELEMETRY_CAP
|
||||
LogTelemetryEvent({
|
||||
level: "info"
|
||||
message: resolveInfo
|
||||
fingerprint: ["INV-D1 tail-resolve", source]
|
||||
})
|
||||
end if
|
||||
' the tail overtook the frozen playhead: resolve forward (ResolveLiveTail), don't heal.
|
||||
m.playbackTelemetry.RecordTailResolve(source)
|
||||
m.transport.ResolveLiveTail()
|
||||
ApplyTransport()
|
||||
else if action = PlayerCoordinatorLogic.SafetyAction.FinishEof
|
||||
@@ -836,19 +828,6 @@ function EnforceTransportFreeze(source as string) as void
|
||||
end if
|
||||
end function
|
||||
|
||||
' A heal loop that ran past the telemetry cap still reports its true size: one tally event when the
|
||||
' content ends (close or content switch). Loop size is the discriminator between a singleton heal and a
|
||||
' fight the player lost for minutes — the capped per-event stream can no longer show it.
|
||||
function SendHealSummary() as void
|
||||
if m.healCount > INV_D1_TELEMETRY_CAP
|
||||
LogTelemetryEvent({
|
||||
level: "warning"
|
||||
message: `INV-D1 heal: ${m.healCount} heals over one content (${m.healCount - INV_D1_TELEMETRY_CAP} past the telemetry cap)`
|
||||
fingerprint: ["INV-D1 heal suppressed"]
|
||||
})
|
||||
end if
|
||||
end function
|
||||
|
||||
' The Video node reached state=error. ErrorDialogController decides retry-vs-dialog; the coordinator applies
|
||||
' (replay the next URL, or show the scene-level TimedDialog).
|
||||
function OnVideoError() as void
|
||||
@@ -863,12 +842,15 @@ function OnVideoError() as void
|
||||
errorData = GetPlayerErrorData(content.videoId, errorInfo)
|
||||
' NoTelemetry: ReportVideoError below already telemeters this.
|
||||
LogErrorNoTelemetry(errorData.title, errorData.body)
|
||||
' read before deciding: a retry advances content.url and its index to the next stream url.
|
||||
failedUrl = content.url
|
||||
failedUrlIndex = content.playletStreamUrlIndex
|
||||
|
||||
decision = ErrorDialogController.DecideVideoError(content, errorInfo, m.videoPlayedSuccessfully)
|
||||
|
||||
if decision.action = ErrorDialogController.Action.Retry
|
||||
LogInfo("error retry -> next stream url=", decision.nextUrl)
|
||||
ReportVideoError(errorData, content.url, content.playletStreamUrls, content.playletStreamUrlIndex, false)
|
||||
m.playbackTelemetry.ReportVideoError(errorData, errorInfo, failedUrl, failedUrlIndex, false)
|
||||
' the controller already advanced content.url/index; replay it from the initial position (live edge /
|
||||
' timestamp / percent watched). Swallow the next finished edge.
|
||||
m.ignoreNextFinished = true
|
||||
@@ -879,7 +861,7 @@ function OnVideoError() as void
|
||||
end if
|
||||
|
||||
' a retry isn't possible: report it and show the error dialog (swallowing the trailing finished edge).
|
||||
ReportVideoError(errorData, content.url, content.playletStreamUrls, content.playletStreamUrlIndex, true)
|
||||
m.playbackTelemetry.ReportVideoError(errorData, errorInfo, failedUrl, failedUrlIndex, true)
|
||||
m.ignoreNextFinished = true
|
||||
ShowErrorDialog({ title: errorData.title, message: errorData.body })
|
||||
end function
|
||||
@@ -1149,10 +1131,11 @@ function OnVideoContentJobDone(event as object) as void
|
||||
return
|
||||
end if
|
||||
|
||||
m.playbackTelemetry.OnMetadataDone()
|
||||
content = m.top.content
|
||||
|
||||
if not info.success
|
||||
LogError(`VideoContentJob FAILED: ${info.error}\nbackend: ${ContentBackend(content)}`)
|
||||
m.playbackTelemetry.ReportContentJobFailure(info.error)
|
||||
decision = ErrorDialogController.DecideContentJobFailure(content, info.error)
|
||||
ShowErrorDialog(decision)
|
||||
Lounge.SendOnStateChange()
|
||||
@@ -1168,9 +1151,6 @@ function OnVideoContentJobDone(event as object) as void
|
||||
' fill them in for VOD.
|
||||
isLive = content <> invalid and content.Live = true
|
||||
m.transport.SetContent(isLive, 2000, false)
|
||||
SendHealSummary() ' the previous content's capped heal tally, if any
|
||||
m.healCount = 0
|
||||
m.tailResolveCount = 0
|
||||
' live floor: how far back the DVR window reaches (0 = unknown -> the brain keeps the [0, edge] clamp).
|
||||
' The generated DASH anchors t=0 to the window start, so floor = edge - window as the session outlives it.
|
||||
' The same window decides rewindability: a buffer-sized window means no live trickplay at all.
|
||||
@@ -1403,6 +1383,8 @@ end function
|
||||
' EOF / close lifecycle.
|
||||
'-------------------------------------------------------------------------------
|
||||
function OnPlaybackFinished() as void
|
||||
' before PlayNext/ClosePlayer: either can close this player, and send its summary, synchronously.
|
||||
m.playbackTelemetry.OnFinished()
|
||||
LogDebug("playback finished -> PlayNext or close")
|
||||
if not VideoQueueUtils.PlayNext(m.videoQueue, m.invidious, m.preferences)
|
||||
ClosePlayer()
|
||||
@@ -1414,111 +1396,22 @@ end function
|
||||
' the retry-vs-dialog decision is ErrorDialogController). 10s countdown on "Play next video"(default) /
|
||||
' "Cancel"; any key cancels the countdown; response -> PlayNext or close.
|
||||
'-------------------------------------------------------------------------------
|
||||
' Build a structured error record from the Video node's error fields for telemetry. Always returns a record —
|
||||
' callers dereference .title/.body unconditionally, so a state=error with no errorInfo must still produce one.
|
||||
' Always returns a record — callers dereference .title/.body unconditionally, so a state=error with no errorInfo
|
||||
' must still produce one.
|
||||
function GetPlayerErrorData(videoId as string, errorInfo as object) as object
|
||||
errorMsg = m.top.errorMsg
|
||||
errorCode = m.top.errorCode
|
||||
errorStr = m.top.errorStr
|
||||
title = Tr(Locale.VideoPlayer.ErrorPlayingVideo).Replace("%1", videoId)
|
||||
body = `errorMsg: ${errorMsg}\nerrorCode: ${errorCode}\nerrorStr: ${errorStr}`
|
||||
fingerprint = [
|
||||
Locale.VideoPlayer.ErrorPlayingVideo
|
||||
errorMsg
|
||||
errorCode
|
||||
]
|
||||
body = `errorMsg: ${m.top.errorMsg}\nerrorCode: ${m.top.errorCode}\nerrorStr: ${m.top.errorStr}`
|
||||
if errorInfo <> invalid
|
||||
for each key in errorInfo
|
||||
body += `\n${key}: ${errorInfo[key]}`
|
||||
end for
|
||||
fingerprint.Append([
|
||||
errorInfo.source
|
||||
errorInfo.ignored
|
||||
errorInfo.category
|
||||
errorInfo.errcode
|
||||
errorInfo.drmerrcode
|
||||
])
|
||||
end if
|
||||
return { title: title, body: body, fingerprint: fingerprint }
|
||||
end function
|
||||
|
||||
function ContentBackend(content as object) as string
|
||||
if content <> invalid and not StringUtils.IsNullOrEmpty(content.backend)
|
||||
return content.backend
|
||||
end if
|
||||
return "unknown"
|
||||
end function
|
||||
|
||||
' Send a stream error to telemetry. For malformed-data errors, attach the last generated DASH/HLS manifest and
|
||||
' player response so the failure can be diagnosed from the report.
|
||||
function ReportVideoError(errorData as object, url as dynamic, urls as object, urlIndex as dynamic, shownInDialog as boolean) as void
|
||||
if errorData = invalid
|
||||
return
|
||||
end if
|
||||
attachments = invalid
|
||||
if errorData.body.Instr("malformed data") <> -1 or errorData.body.Instr("invalid pathname") <> -1
|
||||
attachments = [{
|
||||
filename: "last_generated_dash.xml"
|
||||
content_type: "plain/text"
|
||||
data: ValidString(ReadAsciiFile("cachefs:/last_generated_dash.xml"))
|
||||
}, {
|
||||
filename: "last_generated_hls.m3u8"
|
||||
content_type: "plain/text"
|
||||
data: ValidString(ReadAsciiFile("cachefs:/last_generated_hls.m3u8"))
|
||||
}, {
|
||||
filename: "last_player_response.json"
|
||||
content_type: "application/json"
|
||||
data: ValidString(ReadAsciiFile("cachefs:/last_player_response.json"))
|
||||
}]
|
||||
end if
|
||||
potAttached = false
|
||||
potSource = "none"
|
||||
loggedIn = false
|
||||
content = m.top.content
|
||||
if content <> invalid
|
||||
potAttached = ValidBool(content.potAttached)
|
||||
loggedIn = ValidBool(content.loggedIn)
|
||||
if not StringUtils.IsNullOrEmpty(content.potSource)
|
||||
potSource = content.potSource
|
||||
end if
|
||||
end if
|
||||
backend = ContentBackend(content)
|
||||
isLive = m.transport.isLive
|
||||
message = [
|
||||
errorData.title
|
||||
errorData.body
|
||||
`Dialog shown: ${shownInDialog}`
|
||||
`Position: ${m.top.position}`
|
||||
`Duration: ${m.top.duration}`
|
||||
`Url: ${url}`
|
||||
"Urls: " + FormatJson(urls)
|
||||
`Url index: ${urlIndex}`
|
||||
`pot_attached: ${potAttached}`
|
||||
`pot_source: ${potSource}`
|
||||
`logged_in: ${loggedIn}`
|
||||
`backend: ${backend}`
|
||||
`is_live: ${isLive}`
|
||||
].Join(Chr(10))
|
||||
errorData.fingerprint.Push(shownInDialog)
|
||||
errorData.fingerprint.Push(potAttached)
|
||||
errorData.fingerprint.Push(potSource)
|
||||
errorData.fingerprint.Push(loggedIn)
|
||||
errorData.fingerprint.Push(backend)
|
||||
errorData.fingerprint.Push(isLive)
|
||||
if shownInDialog
|
||||
level = "error"
|
||||
else
|
||||
level = "warning"
|
||||
end if
|
||||
LogTelemetryEvent({
|
||||
level: level
|
||||
message: message
|
||||
fingerprint: errorData.fingerprint
|
||||
attachments: attachments
|
||||
})
|
||||
return { title: title, body: body }
|
||||
end function
|
||||
|
||||
function ShowErrorDialog(decision as object) as void
|
||||
' first: a blocked dialog closes this player, and sends its summary, synchronously (below).
|
||||
m.playbackTelemetry.OnErrorDialog()
|
||||
buttons = [Tr(Locale.Buttons.PlayNextVideo), Tr(Locale.Buttons.Cancel)]
|
||||
dialog = DialogUtils.ShowTimedDialogButtons(decision.message, decision.title, buttons, 0, 10, true)
|
||||
if dialog <> invalid
|
||||
@@ -1571,7 +1464,7 @@ function OnClose() as void
|
||||
end if
|
||||
m.onCloseCalled = true
|
||||
m.top.previousPlayer = invalid
|
||||
SendHealSummary()
|
||||
m.playbackTelemetry.SendSummary()
|
||||
|
||||
' A closed player must not react to anything anymore. The onCloseCalled guards already make the handlers
|
||||
' no-ops; unobserving stops the traffic at the source — late device edges from the async stop, a stray
|
||||
@@ -1584,6 +1477,8 @@ function OnClose() as void
|
||||
m.top.unobserveField("duration")
|
||||
m.top.unobserveField("thumbnailTiles")
|
||||
m.top.unobserveField("control")
|
||||
m.top.unobserveField("bufferingStatus")
|
||||
m.top.unobserveField("playStartInfo")
|
||||
m.top.unobserveField("close")
|
||||
content = m.top.content
|
||||
if content <> invalid
|
||||
@@ -1634,7 +1529,7 @@ function OnClose() as void
|
||||
try
|
||||
m.top.control = VideoControl.Stop
|
||||
catch error
|
||||
LogError("error stopping video:", ErrorUtils.Format(error))
|
||||
m.playbackTelemetry.ReportStopFailure(error)
|
||||
end try
|
||||
|
||||
m.top.content = invalid
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
import "pkg:/components/VideoPlayerDev/VideoNode.bs"
|
||||
import "pkg:/source/utils/RemoteKeys.bs"
|
||||
import "pkg:/source/utils/StringUtils.bs"
|
||||
import "pkg:/source/utils/Types.bs"
|
||||
|
||||
namespace Tests
|
||||
|
||||
@SGNode("VideoPlayerDevMock")
|
||||
@suite
|
||||
class PlaybackTelemetryWiringTests extends Rooibos.BaseTestSuite
|
||||
|
||||
protected override function beforeEach()
|
||||
m.top.callFunc("TestSetup")
|
||||
end function
|
||||
|
||||
function State(state as string) as void
|
||||
m.top.callFunc("TestSetState", state)
|
||||
end function
|
||||
|
||||
function SetContent(urls as object) as void
|
||||
content = CreateObject("roSGNode", "ContentNode")
|
||||
content.addField("videoId", "string", false)
|
||||
content.addField("backend", "string", false)
|
||||
content.addField("playletStreamUrls", "array", false)
|
||||
content.addField("playletStreamUrlIndex", "integer", false)
|
||||
content.addField("playletStreamSource", "string", false)
|
||||
content.setFields({
|
||||
videoId: "vid1"
|
||||
backend: "playlet"
|
||||
url: urls[0]
|
||||
playletStreamUrls: urls
|
||||
playletStreamUrlIndex: 0
|
||||
playletStreamSource: "adaptiveFormats"
|
||||
})
|
||||
m.top.content = content
|
||||
end function
|
||||
|
||||
function BufferingStatus(isUnderrun as boolean) as void
|
||||
m.top.bufferingStatus = { actualStart: 0, isUnderrun: isUnderrun, percentage: 0, prebufferDone: false }
|
||||
end function
|
||||
|
||||
function SentSummary() as object
|
||||
event = m.global.telemetry.LogEvent
|
||||
m.assertEqual(event.fingerprint, ["playback summary"])
|
||||
return StringUtils.ParseJsonSafe(event.message)
|
||||
end function
|
||||
|
||||
function Close() as object
|
||||
m.top.close = true
|
||||
' an error dialog still up was closed by OnClose; drop it from the scene for the next test.
|
||||
m.top.getScene().dialog = invalid
|
||||
return m.SentSummary()
|
||||
end function
|
||||
|
||||
function HttpError() as void
|
||||
m.top.errorMsg = "There was an error in the HTTP response."
|
||||
m.top.errorCode = -1
|
||||
m.top.errorStr = "reader pick stream error:HTTP error"
|
||||
m.top.errorInfo = { category: "http", source: "buffer:reader", ignored: false }
|
||||
end function
|
||||
|
||||
@describe("playback telemetry wiring")
|
||||
|
||||
@it("state edges and bufferingStatus reach the summary: an underrun counts")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.State(VideoState.Playing)
|
||||
m.State(VideoState.Buffering)
|
||||
m.BufferingStatus(true)
|
||||
m.State(VideoState.Playing)
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.underrun_count, 1)
|
||||
m.assertTrue(ValidInt(summary.first_playing_at_ms) >= 0, "the first playing was recorded")
|
||||
m.assertEqual(summary.backend, "playlet")
|
||||
m.assertEqual(summary.stream_source, "adaptiveFormats")
|
||||
m.assertFalse(summary.DoesExist("drm"), "an unset drmParams on a ContentNode reads as no DRM")
|
||||
m.assertFalse(summary.DoesExist("stream_url_index"))
|
||||
m.assertEqual(summary.outcome, "closed")
|
||||
end function
|
||||
|
||||
@it("a buffering whose bufferingStatus is no underrun is not counted")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.State(VideoState.Playing)
|
||||
m.State(VideoState.Buffering)
|
||||
m.BufferingStatus(false)
|
||||
m.State(VideoState.Playing)
|
||||
m.assertFalse(m.Close().DoesExist("underrun_count"))
|
||||
end function
|
||||
|
||||
@it("every playStartInfo reaches the summary")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.State(VideoState.Playing)
|
||||
m.top.playStartInfo = { start_type: "init", total_dur: 0.5 }
|
||||
m.top.playStartInfo = { start_type: "cseek", total_dur: 0.25 }
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.play_start_count, 2)
|
||||
m.assertEqual(summary.play_start_infos[0].start_type, "init")
|
||||
m.assertEqual(summary.play_start_infos[1].start_type, "cseek")
|
||||
end function
|
||||
|
||||
@it("a retry: the report names the url that failed; the summary, the one that played")
|
||||
function _()
|
||||
m.SetContent(["http://a", "http://b"])
|
||||
m.HttpError()
|
||||
m.State(VideoState.Error)
|
||||
report = m.global.telemetry.LogEvent
|
||||
m.assertEqual(report.level, "warning", "retried: not shown to the viewer")
|
||||
m.assertTrue(report.message.InStr("Url: http://a") > 0 and report.message.InStr("Url index: 0") > 0, "got: " + report.message)
|
||||
m.State(VideoState.Playing)
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.error_count, 1)
|
||||
m.assertEqual(summary.stream_url_index, 1)
|
||||
m.assertEqual(summary.outcome, "closed")
|
||||
end function
|
||||
|
||||
@it("an error with no retry left ends in error")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.State(VideoState.Playing)
|
||||
m.HttpError()
|
||||
m.State(VideoState.Error)
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.outcome, "error")
|
||||
m.assertEqual(summary.error_count, 1)
|
||||
end function
|
||||
|
||||
@it("content that never loaded ends in error, with no player error")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.top.callFunc("TestContentJobFailed", "content job failed")
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.outcome, "error")
|
||||
m.assertFalse(summary.DoesExist("error_count"))
|
||||
m.assertTrue(ValidInt(summary.metadata_done_at_ms) >= 0, "the content job's result is recorded")
|
||||
end function
|
||||
|
||||
@it("after the close, a late playStartInfo or bufferingStatus reaches nothing")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.State(VideoState.Playing)
|
||||
m.top.playStartInfo = { start_type: "init", total_dur: 0.5 }
|
||||
m.State(VideoState.Buffering)
|
||||
m.assertEqual(m.Close().play_start_count, 1)
|
||||
m.top.playStartInfo = { start_type: "cseek", total_dur: 0.25 }
|
||||
m.top.bufferingStatus = { isUnderrun: true, percentage: 0, prebufferDone: false, actualStart: 0 }
|
||||
m.top.callFunc("TestResendSummary")
|
||||
resent = m.SentSummary()
|
||||
m.assertEqual(resent.play_start_count, 1)
|
||||
m.assertFalse(resent.DoesExist("underrun_count"))
|
||||
end function
|
||||
|
||||
@it("finishing ends in finished, sent from within the finish")
|
||||
function _()
|
||||
m.SetContent(["http://stream"])
|
||||
m.top.callFunc("TestWireQueueClose") ' the stub queue closes the player on closePlayer, as the real one does
|
||||
m.State(VideoState.Playing)
|
||||
m.State(VideoState.Finished)
|
||||
m.assertEqual(m.SentSummary().outcome, "finished")
|
||||
end function
|
||||
|
||||
@it("a heal loop: every heal counted, the first 3 sampled, none sent on its own")
|
||||
function _()
|
||||
m.State(VideoState.Playing) ' the first playing opens the transport's ready gate
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
m.global.telemetry.LogEvent = {}
|
||||
for i = 1 to 5
|
||||
m.State(VideoState.Playing) ' playing under a scrub: healed
|
||||
end for
|
||||
m.assertInvalid(m.global.telemetry.LogEvent.message, "a heal sends nothing until the summary")
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.heal_count, 5)
|
||||
m.assertEqual(summary.heal_samples.Count(), 3)
|
||||
m.assertEqual(summary.heal_samples[0].source, "OnVideoState")
|
||||
m.assertFalse(summary.DoesExist("tail_resolve_count"))
|
||||
end function
|
||||
|
||||
@it("a live tail the sliding floor overtook is a tail resolve, not a heal")
|
||||
function _()
|
||||
m.State(VideoState.Playing) ' the first playing opens the transport's ready gate
|
||||
m.top.callFunc("TestSetLive", 43200000)
|
||||
m.top.position = 28805.0
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
m.State(VideoState.Playing) ' the device force-resumes the pause the tail overtook
|
||||
summary = m.Close()
|
||||
m.assertEqual(summary.tail_resolve_count, 1)
|
||||
m.assertEqual(summary.tail_resolve_samples[0].source, "OnVideoState")
|
||||
m.assertFalse(summary.DoesExist("heal_count"))
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -26,7 +26,7 @@ function TestSetup() as void
|
||||
m.global.logger = CreateObject("roSGNode", "Logger")
|
||||
end if
|
||||
|
||||
' ReportVideoError -> LogTelemetryEvent writes m.global.telemetry.LogEvent; stub it so the error path runs.
|
||||
' LogTelemetryEvent (error reports, the playback summary on close) writes m.global.telemetry.LogEvent; stub it.
|
||||
if m.global.telemetry = invalid
|
||||
m.global.addField("telemetry", "node", false)
|
||||
telemetry = CreateObject("roSGNode", "Node")
|
||||
@@ -80,7 +80,7 @@ function TestSetup() as void
|
||||
' nudge counter above — stacked observers fire a handler once per prior TestSetup on every write,
|
||||
' and OnPosition's latency learning reads two identical fires as a CONFIRMED min-gap, poisoning
|
||||
' LiveEdgeMs for any live test that runs after another test in the suite.
|
||||
for each deviceField in ["state", "position", "duration", "close", "thumbnailTiles", "control"]
|
||||
for each deviceField in ["state", "position", "duration", "close", "thumbnailTiles", "control", "bufferingStatus", "playStartInfo"]
|
||||
m.top.unobserveField(deviceField)
|
||||
end for
|
||||
|
||||
@@ -196,6 +196,19 @@ function TestPlaybackErrorDialog(errorFields as object) as object
|
||||
return result
|
||||
end function
|
||||
|
||||
' TestContentJobFailed — the VideoContentJob's failure result, minus the job: runs the REAL OnVideoContentJobDone.
|
||||
function TestContentJobFailed(errorMessage as string) as void
|
||||
OnVideoContentJobDone({
|
||||
info: { success: false, cancel: false, error: errorMessage }
|
||||
getRoSGNode: function() as dynamic
|
||||
return invalid
|
||||
end function
|
||||
getInfo: function() as object
|
||||
return m.info
|
||||
end function
|
||||
})
|
||||
end function
|
||||
|
||||
' TestCoordinatorFields — every non-function key on the coordinator's m, for the unmodeled-axis meta-test
|
||||
' (the coordinator twin of the brain's reflection test). Call AFTER TestSetup so Initialize/OnNodeReady have
|
||||
' populated m. The ONLY filtering here is the two DYNAMICALLY-named runtime families ("__delay_<uuid>" and
|
||||
@@ -243,6 +256,12 @@ function TestWireQueueClose() as void
|
||||
m.videoQueue.observeFieldScoped("closePlayer", FuncName(OnTestQueueClose))
|
||||
end function
|
||||
|
||||
' TestResendSummary — send the playback summary again after the close, so a spec can see whether anything reached
|
||||
' the Recorder since.
|
||||
function TestResendSummary() as void
|
||||
m.playbackTelemetry.SendSummary()
|
||||
end function
|
||||
|
||||
function OnTestQueueClose() as void
|
||||
if m.videoQueue.closePlayer
|
||||
m.top.close = true
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
<field id="errorMsg" type="string" />
|
||||
<field id="errorStr" type="string" />
|
||||
<field id="errorInfo" type="assocarray" />
|
||||
<field id="bufferingStatus" type="assocarray" alwaysNotify="true" />
|
||||
<field id="playStartInfo" type="assocarray" alwaysNotify="true" />
|
||||
<!-- AutoBind deps + layout (set by TestSetup; NOT bound). -->
|
||||
<field id="appController" type="node" />
|
||||
<field id="jobQueue" type="node" />
|
||||
@@ -50,6 +52,7 @@
|
||||
<function name="TestSetState" />
|
||||
<function name="TestSnapshot" />
|
||||
<function name="TestWireQueueClose" />
|
||||
<function name="TestResendSummary" />
|
||||
<function name="TestSetControl" />
|
||||
<function name="TestSetLive" />
|
||||
<function name="TestSeedSponsorBlock" />
|
||||
@@ -58,6 +61,7 @@
|
||||
<function name="TestFinishChromeFadeOut" />
|
||||
<function name="TestPlaybackErrorDialog" />
|
||||
<function name="TestCoordinatorFields" />
|
||||
<function name="TestContentJobFailed" />
|
||||
</interface>
|
||||
<children>
|
||||
<Timer id="autoHide" duration="5" repeat="false" />
|
||||
|
||||
@@ -108,23 +108,6 @@ namespace Tests
|
||||
m.assertEqual(snap.transportMode, TransportController.Mode.Idle, "the transport resolved instead of fighting")
|
||||
m.assertEqual(snap.control, VideoControl.Resume, "resumed forward, not re-paused")
|
||||
m.assertEqual(Int(m.top.seek * 1000), 28860000, "the resume parks a full margin above the trigger (28800s + 60s)")
|
||||
' the resolution telemeters at info level (never as a heal) with its per-content ordinal.
|
||||
sent = m.global.telemetry.LogEvent
|
||||
m.assertEqual(sent.level, "info")
|
||||
m.assertTrue(sent.message.InStr("INV-D1 tail-resolve") = 0, "got: " + sent.message)
|
||||
m.assertTrue(sent.message.InStr("resolve=1") > 0)
|
||||
end function
|
||||
|
||||
@it("heal telemetry stops at the cap while the occurrences keep counting")
|
||||
function _()
|
||||
' a frozen VOD scrub the device keeps flipping to playing: 5 heals, but only 3 events may leave.
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
for i = 1 to 5
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
end for
|
||||
sent = m.global.telemetry.LogEvent
|
||||
m.assertTrue(sent.message.InStr("heal=3") > 0, "telemetry must stop at the 3rd heal; last sent: " + sent.message)
|
||||
end function
|
||||
|
||||
@it("a sentinel-valued duration report cannot anchor the live-edge fallback clock")
|
||||
@@ -743,7 +726,7 @@ namespace Tests
|
||||
classified[name] = "dep"
|
||||
end for
|
||||
' controllers (plain .bs class instances).
|
||||
for each name in ["transport", "sponsorblock"]
|
||||
for each name in ["transport", "sponsorblock", "playbackTelemetry"]
|
||||
classified[name] = "controller"
|
||||
end for
|
||||
' cached child nodes / timers / animations / reusable helpers (structure, not state).
|
||||
@@ -759,7 +742,7 @@ namespace Tests
|
||||
classified[name] = "axis"
|
||||
end for
|
||||
' flags / scratch — one-shot latches and counters with a single consuming path.
|
||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "seekToPercent", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive", "healCount", "tailResolveCount"]
|
||||
for each name in ["onCloseCalled", "ignoreNextFinished", "videoPlayedSuccessfully", "firstFrameSeen", "showFullScreenHint", "repauseAfterSeek", "seekToPercent", "watchTimeMarker", "reportWatchTime", "errorDialogNode", "lastCommitSeq", "lastFinishSeq", "liveAstSeconds", "liveFallbackEdgeMs", "liveFallbackAtSeconds", "liveBadgeHoldActive"]
|
||||
classified[name] = "flag"
|
||||
end for
|
||||
' NOT coordinator state — node-scope + test-environment entries, pinned EXPLICITLY (no hidden
|
||||
@@ -819,7 +802,7 @@ namespace Tests
|
||||
container.fullscreen = true
|
||||
' close the player (what the queue does when replacing the video), then throw every signal a dead
|
||||
' player might still receive at it: fullscreen flips (the * key), device edges from the async stop,
|
||||
' a stray control/seek write, late thumbnails, a second close. OnClose unobserves them all.
|
||||
' a stray control/seek write, late thumbnails and buffering/start info, a second close. OnClose unobserves them all.
|
||||
m.top.close = true
|
||||
container.fullscreen = false
|
||||
container.fullscreen = true
|
||||
@@ -831,6 +814,8 @@ namespace Tests
|
||||
m.top.duration = 99.0
|
||||
m.top.seek = 5.0
|
||||
m.top.thumbnailTiles = { x: [{ htiles: 1 }] }
|
||||
m.top.bufferingStatus = { isUnderrun: true, percentage: 0, prebufferDone: false, actualStart: 0 }
|
||||
m.top.playStartInfo = { start_type: "cseek", total_dur: 0.1 }
|
||||
m.top.close = true
|
||||
m.assertTrue(true, "no crash: the closed player ignored all post-close traffic")
|
||||
end function
|
||||
@@ -865,21 +850,6 @@ namespace Tests
|
||||
m.assertTrue(m.Snap().onCloseCalled, "the finish closed the player from within the position tick")
|
||||
end function
|
||||
|
||||
' Also at the end (closes the player): a heal loop that ran past the telemetry cap reports its
|
||||
' true size in one tally event when the content ends.
|
||||
@it("the close summary carries a capped heal loop's true size")
|
||||
function _()
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, true)
|
||||
m.top.callFunc("TestKey", RemoteKeys.Left, false)
|
||||
for i = 1 to 5
|
||||
m.top.callFunc("TestSetState", VideoState.Playing)
|
||||
end for
|
||||
m.top.close = true
|
||||
summary = m.global.telemetry.LogEvent
|
||||
m.assertTrue(summary.message.InStr("5 heals") > 0, "got: " + summary.message)
|
||||
m.assertTrue(summary.message.InStr("2 past the telemetry cap") > 0, "got: " + summary.message)
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
Reference in new issue
Block a user