Skip to content

fix(player): limit expired-link refetch to restored playback - #876

Open
CaptainMusX wants to merge 1 commit into
ProdigyV21:mainfrom
CaptainMusX:fix/pr817-resume-refetch-followup
Open

CaptainMusX wants to merge 1 commit into
ProdigyV21:mainfrom
CaptainMusX:fix/pr817-resume-refetch-followup

Conversation

@CaptainMusX

Copy link
Copy Markdown
Contributor

背景

#817 已于 2026-11-02 合并。合并前约 2 分钟,silentbil 在复测评论里对 PlayerScreen.kt 的 resume refetch 提了两条备注,当时没有代码回应:

  1. refetch 对「自动挑选的源上的任意 transient startup error」都触发,不只 resume/restore。全新播放遇到死源也会先跑完整 reloadStreams(forceRefresh = true) 再 failover,带来明显延迟;PARSING_CONTAINER_* 错误也会触发,但同一文件换新链接并无帮助。建议限定为 resume/restore + network/HTTP 错误码。
  2. startupSameSourceRefreshAttempted 在已有的 heavy-timeout 重解析之前就置位,导致那条更廉价的路径不再执行。

本 PR 只收尾这两条,不含其他改动。

改动

  • 新增 StartupSourceRecovery:把「拉新源列表」与「同源重解析」拆成两个独立预算(freshRefetchAttempted / sameSourceRefreshAttempted),启动时 reset()。
  • tryFreshRefetch() 同时要求:
    • networkOrHttpFailure = 超时或 IO_UNSPECIFIED / IO_NETWORK_CONNECTION_FAILED / IO_BAD_HTTP_STATUS(容器解析错误不再触发);
    • resumeOrRestored = startPositionMs > 0、savedPosition > 0,或 recentSource 与当前标题/剧集匹配(appliesTo + findRecentSourceMatch)。
  • PlayerScreen 接入新类;启动遥测分别上报 refresh / refetch 两个计数,startupRetries 改用合计预算。
  • trySameSourceRefresh() 独立计数,heavy-timeout 重解析不再被提前吃掉。

验证

  • ./gradlew :app:testSideloadDebugUnitTest --tests 'com.arflix.tv.ui.screens.player.StartupSourceRecoveryTest':4 tests, 0 failures, 0 errors。
  • compileSideloadDebugKotlin / compileSideloadDebugUnitTestKotlin 通过(仅有仓库既有的 deprecation 警告)。
  • git diff --check 通过。

范围与风险

  • 只改启动错误分支,未做真机验证;不涉及 UI 或正常播放路径。
  • 基于当前 upstream/main (d1f76342),与 main 无冲突。

Related to #817.

Follow-up to the two resume-refetch notes silentbil left on ProdigyV21#817 before it merged (2026-11-02). The fresh source-list refetch fired for any transient startup error on an automatically picked source, so a dead source on a fresh play paid for a full reloadStreams(forceRefresh = true) first, and PARSING_CONTAINER_* errors triggered a refetch that cannot help. It also set startupSameSourceRefreshAttempted before the existing heavy-timeout re-resolve, silently disabling that cheaper path.

Gate the refetch on resumed/restored playback (startPositionMs, savedPosition, or a recentSource match for the current title/episode) and on timeout / IO_UNSPECIFIED / IO_NETWORK_CONNECTION_FAILED / IO_BAD_HTTP_STATUS; container parse errors now fall through. Split freshRefetchAttempted and sameSourceRefreshAttempted into separate budgets and report both in startup telemetry. Adds StartupSourceRecoveryTest (4 tests, all passing on sideloadDebug).
@github-actions github-actions Bot added the area: android Changes to the Android app or Gradle build label Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: android Changes to the Android app or Gradle build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant