Skip to content

fix(capture): copy PipeWire frames into system memory to stop the green picture - #54

Open
Developer1010x wants to merge 2 commits into
masterfrom
fix/Developer1010x-green-capture
Open

Developer1010x wants to merge 2 commits into
masterfrom
fix/Developer1010x-green-capture

Conversation

@Developer1010x

Copy link
Copy Markdown
Owner

The issue

After #50, an OpenPlay cast connects, negotiates and decodes end to end, but the receiver shows a uniformly green picture instead of the sender's screen (the "Known remaining defect" in #50).

Root cause (hypothesis — not yet confirmed)

Solid green is what an all-zero YUV frame decodes to, so the encoder is being fed empty frames. The decode side is not the suspect: crates/openplay-pipeline/tests/webrtc_loopback.rs carries real decoded frames through the same receiver chain using a videotestsrc source.

The capture source is built in build_capture_element (crates/openplay-pipeline/src/encoder.rs) with pipewiresrc always-copy=false. In that mode PipeWire can pass the portal's DMABuf / shared-memory buffers straight through, and the CPU-side videoconvert that #50 added downstream reads them as zeros.

Duplicates

None found. No open PRs; searching closed PRs for "green", "always-copy" and "dmabuf" turns up only #50, which reported this defect and left it for a follow-up.

The fix

Set always-copy=true on pipewiresrc, so every frame is copied into system memory before videoconvert sees it. That costs one memcpy per frame, which is small next to an H.264 encode. One line plus a comment explaining why.

Verification

NOT VERIFIED on a real cast yet. PipeWire capture is Linux-only and needs a desktop portal plus a human at the consent prompt, so CI cannot exercise it. Do not merge until someone has run, on Linux:

cargo run -p openplay-receiver
OPENPLAY_DUMP_CAPTURE=1 cargo run -p openplay-sender

and confirmed a real picture. If it is still green, the Captured buffer contents log lines say which way to go:

  • pct_nonzero near 0: the portal is delivering empty frames, and this change is not the fix.
  • pct_nonzero high: the frames are fine and the conversion is mangling them, so pin an explicit raw format next.

Why it matters

The green picture is the last known blocker between "a cast connects" and "a cast shows your screen". Until it is fixed, OpenPlay's native protocol does not do its one job, and a cross-machine test or a call for community testers is premature.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant