Repository navigation
fix: keep the video screen's background over the picture on Android 10 - #219
Conversation
- Android 10 and 11 make a SurfaceView's hole with drawColor(CLEAR), which clears everything inside the canvas's clip. Compose draws the SurfaceView into its enclosing layer with no clip, so the hole wiped the screen's background and minimize button, which then showed black. - ClippedContentFrame does what ContentFrame does, with a clip after the resize at the SurfaceView's own bounds, the same rectangle that Android 12 and later clear with punchHole. The video screen and fullscreen use it. - VideoScreenBackgroundTest captures the window while the picture shows and checks that the minimize button and the description are opaque. It fails on Android 10 without the fix. It ends with stopPlayback, as the other emulator tests do, so the next test gets its own PlaybackService. - docs/testing.md and docs/architecture.md describe the test and the frame. Issue #211.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Closes #211
A bug fix that makes the app match openspec/specs/player/spec.md, which already asks for the background to fill the window and for the minimize button, so no OpenSpec change. The maintainer subagent's plan check gave "Fix first" on round 1 (a clip on the 16:9 box would still blacken the bars beside a vertical or 4:3 picture on Android 10), then "Verdict: Build" on round 2. A round 3 about the emulator tests' isolation was stopped by the owner's call: this PR adds no second isolation fix and uses #212's
stopPlaybackhelper instead.What changed and why
Canvas.drawColor(0, PorterDuff.Mode.CLEAR)(AOSP android-10.0.0_r47 and android-11.0.0_r48,SurfaceView.clearSurfaceViewPort). That clears everything inside the canvas's clip. Compose UI 1.12.1 draws an AndroidView into its enclosing layer's canvas with no clip of its own, and nothing on the video screen's path clipped it. So the hole wiped the screen's background and the minimize button, which were drawn before it. Those pixels were transparent in the window, which showed black there. Android 12 and later useCanvas.punchHolebounded to the view (android-12.0.0_r34), so they were fine.ClippedContentFramein:feature:player-uidoes what media3-ui-compose 1.11.1's ContentFrame does with its defaults (SurfaceView, ContentScale.Fit,rememberPresentationState, the shutter whilecoverSurface), plus.clipToBounds()afterresizeWithContentScale. The clip is then the SurfaceView's own rectangle, the same one Android 12 and later clear. The video screen and fullscreen use it in place of ContentFrame. Its KDoc says to compare it with ContentFrame when Media3 updates.VideoScreenBackgroundTest(emulator) opens the test video, waits for its 320x180 picture, pauses, captures the window withcaptureToImage, and checks that the minimize button's and the description's bounds have only opaque pixels, and that the button has more than one color. Without the fix it failed on Android 10: all 12,100 pixels of the button's bounds were transparent. It ends with A video opened offline stays stopped after Try again when a live stream was in the mini player #212'sstopPlayback, as the other emulator tests do. Screenshot tests can't catch this, because layoutlib draws no SurfaceView hole.Not in this PR: the Android 10 three-button navigation bar over fullscreen's exit button, which #212's session is filing as its own issue. The mini player has no SurfaceView, so it isn't affected.
New dependencies
None.
Checklist
Checks
./gradlew --continue spotlessCheck detekt lint test testDebugScreenshotTestDefaultTestSuite assembleDebug :app:assembleDebugAndroidTest -Pandroid.builder.sdkDownload=falsepasses, andscripts/scan_screenshot_tests.pypasses (66 files). The screenshot reference images didn't change.Pre-push gate on ad079a2, on main at c2a4cd8 (the last lines):
Emulator tests (
am instrumentwith HiltTestRunner, all three classes in one run): OK (3 tests) twice on Android 10 (a temporary Pixel 4 AVD, android-29 google_apis arm64, deleted afterwards) and twice on Android 17 (Dewfall_Pixel_6_API_37,-feature -HardwareDecoder).Hand checks, November 22, 2026, one emulator at a time, before the rebase onto fix: keep a failed video's failure when prepare clears an older error #217 (which changed no code this PR touches):
surfacebars beside it.screencapreads 0 non-opaque pixels on the video screen. Fullscreen: 397 non-opaque pixels, a single 1-pixel column at the picture's edge, down from about 389,000 before, black on the blackscrim. Exiting fullscreen returns to portrait, and minimizing to the mini player works.CodeRabbit
Reviewed ad079a2: "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