fix: stabilize explicit-sync and NVDEC lifecycles - #13
Conversation
Reviewer's GuideThis PR stabilizes explicit sync and NVDEC lifecycles by updating ffmpeg-next, correctly handling hardware frame detection and transfer, deferring cached/hotplug wallpaper restoration until layer surfaces are configured, avoiding premature/bufferless layer commits, and ensuring active video playback is stopped cleanly on daemon exit via IPC Stop. Sequence diagram for deferred wallpaper restoration on layer configuresequenceDiagram
participant OutputHandler
participant WaylandState
participant LayerShellHandler
participant WallpaperRestorer
participant RenderState
OutputHandler->>WaylandState: create_render_state_for_output_sync
OutputHandler->>WaylandState: pending_restores.insert
LayerShellHandler->>WaylandState: configure
WaylandState->>WallpaperRestorer: tokio::spawn
WallpaperRestorer->>RenderState: restore_cached_wallpaper
Sequence diagram for IPC Stop handling and video playback shutdownsequenceDiagram
actor IpcClient
participant Daemon
participant RenderState
participant VideoPlayback
participant Systemd
IpcClient->>Daemon: IpcCommand::Stop
Daemon->>RenderState: playback_gen.fetch_add
Daemon->>RenderState: pacer.notify
Daemon->>VideoPlayback: video_playback.stop
Daemon->>Systemd: exit after delay
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
📝 WalkthroughWalkthroughThe daemon now waits for layer-surface configuration before registering render state and restoring cached wallpapers. It sets buffer scale before commits, improves playback shutdown, and updates FFmpeg dependency and hardware-frame handling. ChangesWallpaper playback lifecycle
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DaemonStartup
participant LayerSurface
participant ConfigureHandler
participant RenderStateMap
participant WallpaperCache
DaemonStartup->>LayerSurface: create and queue render state
LayerSurface->>ConfigureHandler: send configure event
ConfigureHandler->>RenderStateMap: register render state
ConfigureHandler->>WallpaperCache: restore cached wallpaper
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@wallr-core/src/daemon/mod.rs`:
- Around line 214-220: The per-output task around render state insertion and
restore_cached_wallpaper must serialize configuration with restoration and
removal. Add a per-output lifecycle generation or cancellation token, invalidate
it in output_destroyed, validate it before restoring and publishing, and move
the render_states insertion until after restoration completes so stale tasks
cannot reinsert destroyed outputs or overwrite newer IPC updates.
- Around line 1274-1276: Remove the initial render-state insertion into the
shared map immediately before the pending_restores insertion. Keep the state
only in wayland_state.pending_restores until the layer-surface configure path
registers it, preserving deferred registration and preventing IPC from targeting
unconfigured surfaces.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: bd6e1bb4-fa44-4e6d-b4dc-bf795868d769
📒 Files selected for processing (3)
Cargo.tomlwallr-core/src/daemon/mod.rswallr-core/src/video/decoder.rs
Summary
ffmpeg-nextto 9.0 and correctly transfer NVDEC hardware frameswp_viewporterRoot causes
SCTK already acknowledges layer-shell configure events. Wallr's extra
layer.commit()raced wgpu-owned presentation and produced a bufferless explicit-sync commit, which NVIDIA rejected withwp_linux_drm_syncobj_surface_v1: Missing buffer.Cached startup and hotplug restoration could attach a buffer before configure or race output removal. Restoration is now configure-gated and lifecycle-cancelled.
Fractionally scaled outputs combined physical mode dimensions with Wayland's integer buffer scale. Native buffers now remain at scale 1 and are mapped to the compositor-provided logical size through
wp_viewporter.The playback scheduler discarded decoded frames whose PTS was slightly in the future. NVDEC could therefore advance while the displayed frame remained frozen. Wallr now retains the first future frame and presents it when due.
Verification
cargo fmt --all --checkcargo check --workspacecargo clippy --workspace --all-targets -- -D warningscargo test --workspace(46 passed)cargo build --release --bin wallrset_buffer_scale(1)andwp_viewport.set_destination(3072, 1728)Fixes #12