Repository navigation
fix: keep a failed video's failure when prepare clears an older error - #217
Conversation
- TryAgainOfflineTest reproduces #212 without a live stream or timing: the first video's files fail, so the player holds a network error in the mini player, and then a second video opens with the network off. It checks that the failure is still NETWORK once the session's prepare has run on the empty player, and that the one "Try again" then plays the video. It fails on main with "expected NETWORK but was null". - FakeNetwork switches the fake YouTube calls and AssetMedia off and on, and TestVideo gets a second video with the same files, which the same search finds. Both start as before, so SearchThenPlayTest is unchanged. - Both tests end with stopPlayback, which stops PlaybackService, because a service that outlives a test keeps that test's Hilt objects, and the next test's connection then waits for a session forever. The new test timed out that way after SearchThenPlayTest. - docs/testing.md describes the tests and the fakes.
- ExoPlayer clears an error only in prepare. When a video's links fail, the player is left empty, and the session's prepare then clears the error of the item before it, such as a live stream that failed in the mini player while the links loaded. PlaybackService took that as a player that plays again and cleared the new video's failure, so the video screen's one "Try again" retried only the details, and the video stayed stopped (#212). - clearsFailure clears it only while the player has an item, so play after a failure still clears it, and an empty player keeps the failure that its links reported. - docs/architecture.md's Failures bullet says so.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Closes #212
A bug fix that makes the app match openspec/specs/player/spec.md's "Details and playback both fail" scenario, so no OpenSpec change. The maintainer subagent's plan check gave "Verdict: Build" on the second round. The first round's "Fix first" asked for the whole hand-check list, which ran as listed below.
What changed and why
prepare()(ExoPlayerImpl at 1.11.1). With the network off, the live stream in the mini player failed (errorCode 2001) while the new video's links loaded. The links then failed too, so the service reported NETWORK and left the player empty. The session's queuedprepare()then ran on that empty player and cleared the live stream's old error.onPlayerErrorChanged(null)took that as a player that plays again, and cleared the new video's NETWORK failure. The screen then had a details failure but no playback failure, so its one "Try again" retried only the details (sharesFailurewas false), and the video area showed the empty, ended player: the disabled "Play again" at 0:00 from the issue. Without an earlier player error, thatprepare()fires no error change, which is why it needed something in the mini player to fail.clearsFailure(errorGone, hasItem)in PlaybackErrors.kt: PlaybackService clears the failure only while the player has an item. Play from the notification after a failure prepares the same item again, so it still clears.PlaybackConnection.preparestill clears the failure for every new start. docs/architecture.md's Failures bullet says so.TryAgainOfflineTest(emulator) reproduces it without a live stream or timing. The first video's files fail, so the player holds a network error in the mini player. Then a second video opens with the network off. The test waits until the player is ended with no item, which it is only once the session's prepare has run on the empty player, and checks that the failure is still NETWORK. Then it turns the network on and checks that the one "Try again" plays the video. With only the test commit (the test commit, ee291f5, on f0aa199), it failed on the Android 17 emulator withexpected:<NETWORK> but was:<null>. With the fix, it passes.FakeNetworkswitches the fake YouTube calls and AssetMedia off and on. TestVideo has a second video with the same files, which the same search finds. Both start on, so SearchThenPlayTest runs as before.stopPlayback, which stops PlaybackService. The tests share one process. A service that outlives a test keeps that test's Hilt objects, so the next test's connection waited for a session forever: TryAgainOfflineTest timed out 2 of 2 times after SearchThenPlayTest before this. Android 10: the video screen's background and minimize button vanish while a video plays #211's branch, in progress, plans to build on this helper.PlaybackErrorsTestcoversclearsFailure's four cases.stopPlayback.Not fixed here: if the old item's error reaches the service after the links' failure was reported but before Media3 sets the empty list, the old item's category replaces the new one's. In #212's case both are NETWORK. The maintainer subagent noted it as not blocking.
New dependencies
None.
Checklist
Checks
./gradlew spotlessCheck detekt lint test testDebugScreenshotTestDefaultTestSuite assembleDebug :app:assembleDebugAndroidTestpasses, andscripts/scan_screenshot_tests.pypasses.Pre-push gate on 56570d8, on main at f0aa199 (the last lines):
Emulator tests (
am instrumentwith HiltTestRunner, both classes in one run): pass 3 of 3 on Android 17 (API 37), and pass on Android 12L (API 32) and Android 10 (API 29).Hand checks, November 22, 2026, one emulator at a time: Android 17 (Dewfall_Pixel_6_API_37,
-feature -HardwareDecoder), Android 12L (Dewfall_Pixel_6_API_32), and Android 10 (a temporary Pixel 4 AVD with android-29 google_apis arm64, since the machine's own one is off limits, deleted afterwards).-feature -HardwareDecoder: the mini player plays its sound, and the video screen says "This video can't play on this phone.").CodeRabbit
Reviewed 56570d8: "No actionable comments were generated", with no inline, nitpick or outside-diff comments. Its title, linked-issue and out-of-scope checks passed. Nothing to fix or decline.
Reviewer
Final verdict: Ready
🤖 Generated with Claude Code