Screen share 6: wgpu video widget (#153) #191
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "screenshare-6-ui-video-widget"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on: screenshare-1-video-frames
What this builds (Screen share plan, Task 6; spec §8.2)
fluxer_ui::widgets::video:video(&bus, key, Fit::{Contain, Cover}) -> Element<'_, M>draws the latest frame of aFrameBuskey, filling its space, letterboxed in--voice-surface-0(Contain) or cropped (Cover). No frame or an invalid frame shows only the surface, so server data never panics.shaderprimitive. Each key has threeR8Unormtextures that are re-uploaded only when the bus generation moves. They are recreated on a size change and dropped once the key leaves the bus. Frames larger than the device's max texture size are downscaled first.video.wgsldoes BT.601 limited range with libyuv's own constants, with bilinear sampling. It has an sRGB-target variant.fluxer_video::{scale, convert}gives RGBA at the drawn size, drawn asimage::Handle::from_rgba. It is cached per generation and size.redraw_subscription(&bus, keys) -> Subscription<()>useswindow::frames().with(Watch). It emits only when a watched generation moved.Watchis public and tested.placement()is the pure geometry, andupload_count(&key)is the counting hook the tests use.testing::Offscreen::{wgpu, tiny_skia}()keeps a renderer and widget tree across frames.testing::rendernow wraps it.CLAUDE.md: theFrameBusis the second sanctioned exception, worded like the image one. Thefluxer-uiREADME is updated.docs/superpowers/research/2026-11-11-screenshare-spikes.md. The file is new on this base; Task 2's branch creates the same file with §1, so the merge needs both sections.How it was tested
tests/video_widget.rs(cfg(not(windows))):missing_key_draws_surface, malformed frames,contain_letterboxes_and_cover_crops,uploads_only_on_new_generation, andWatch.*_wgpuvariants,fallback_matches_wgpu_within_tolerance(both paths are under 2 levels mean error against libyuv, and the counter reads back), andupload_1080p_frame_timeare#[ignore]d and run withFLUXER_SCREENSHOT_TESTS=1.video_widget_pattern_matches_goldenis intests/screenshots.rs, with a row in thedocs/screenshots/README.mdtable. The golden was generated on lavapipe in anubuntu:22.04container (as CI does). There all 13 screenshot tests and all 13 video widget tests passed.FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally.Deviations from the plan
window::frames()only fires on RedrawRequested, so a subscription that emits only on a moved generation stalls whenever the video is slower than the display, and nothing wakes it. So the widget also requests a redraw at most 16.7 ms (video::POLL) after each frame while its key has a frame on the bus. With no key it requests nothing, so an idle call does not spin. Spikes §4.5 has the details; a runtime-side notifier is an option for Screen share 21.iced_wgpu::primitive::Rendereris not public throughiced, so the widget draws an innericed::widget::Shaderon the frame's rectangle. It picks wgpu or the fallback by matchingiced::Renderer::{Primary, Secondary}.src/testing/{mod,offscreen}.rs(Offscreen, needed for the multi-frame upload test and the tiny-skia path).tests/screenshots.rsanddocs/screenshots/README.md, whichscreenshot_suite.rsrequires for every golden.fixtures/golden/video_widget_pattern.png.Watch, and the timing measurement.uploads_only_on_new_generation. It exists on both renderers: the tiny-skia version plus a_wgpuvariant.Closes #153
🤖 Generated with Claude Code
Independent review: Screen share 6 (wgpu video widget), commit
8723980on8b8a359Reviewed
git diff 8b8a359..origin/screenshare-6-ui-video-widgetcold.Plan tests (Task 6 Step 1): all present and asserting what the plan says.
uploads_only_on_new_generation(tiny-skia +_wgpu): counts 1 upload for the first frame, still 1 after two more draws of the same generation, 2 after a new publish (Review Focus 6, widget half: satisfied).contain_letterboxes_and_cover_crops(both renderers) plus pureplacement_*geometry tests.missing_key_draws_surface(both renderers; every pixel isVOICE_SURFACE_0), plusmalformed_frame_draws_surface(short planes, 0x0 frame).fallback_matches_wgpu_within_tolerance: both paths < 2 levels mean error againstfluxer_video::convert::i420_to_rgba, and the counter reads back 42.video_widget_pattern_matches_goldenwith golden +docs/screenshots/README.mdrow.Interfaces:
video(&FrameBus, VideoKey, Fit) -> Element<'_, M>,Fit::{Contain, Cover},redraw_subscription(bus, keys) -> Subscription<()>(window frames, emits only on a moved generation) exist as written. ThreeR8Unormplanes, written withqueue.write_textureonly on a new generation, recreated on a size change, dropped intrimonce the key leaves the bus; BT.601 limited range in libyuv's fixed point; letterbox inVOICE_SURFACE_0; tiny-skia fallback throughscale+convert+Handle::from_rgba.Invariants:
fluxer-uireadsFrameBusonly inwidgets::video(grep confirms).fluxer-videostill depends only onimage+thiserror. CLAUDE.md gets the second exception, worded like the image one. No secrets. Server data cannot panic:validate()(stride >= row bytes, len >= stride*(rows-1)+row) runs before anywrite_texture, so wgpu validation can't fire; invalid or empty frames draw the surface.CI (review worktree):
cargo xtask cigreen, andFLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen (RTX 5090 host): golden matches, the 6 ignored wgpu video tests pass.Findings
window::frames()holds, and this does not break any interface. Suggest afollow-upissue for Screen share 21/22/26: a publish-side notifier next to theFrameBus, or aniced::time::everycheck that emits only on a generation change, so a still does not spin.UPLOADS(the counter behindupload_count, which only tests use) is a process-globalMutex<HashMap<VideoKey, u64>>. Production updates it on every upload and never removes entries. That is one entry per key ever seen (small, but unbounded over a long session) and a global lock on the hot path. Consider#[cfg(any(test, feature = ...))]or pruning it intrim.docs/superpowers/research/2026-11-11-screenshare-spikes.mdis created here with §4 only. Task 2's branch creates the same file with §1, so whoever merges second must keep both sections.Verdict: APPROVED. No blocking findings; ci green locally, including the screenshot step.