fix(linux): retain PipeWire DMA-BUFs through CUDA conversion - #1
Closed
happyme531 wants to merge 1 commit into
Closed
fix(linux): retain PipeWire DMA-BUFs through CUDA conversion#1happyme531 wants to merge 1 commit into
happyme531 wants to merge 1 commit into
Conversation
Owner
Author
|
Superseded by the upstream pull request: LizardByte#5498 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Retain producer-owned PipeWire DMA-BUFs until Sunshine's GL/CUDA conversion has finished reading them.
This fixes intermittent remote-only flashes of coherent content from other windows when using KWin ScreenCast, PipeWire DMA-BUF capture, and NVENC on NVIDIA. The physical display and OBS output remain correct while the streamed frame briefly shows an older or background window.
Root cause
fill_img_dmabuf()duplicates each DMA-BUF file descriptor, but the correspondingpw_bufferwas still left instream_data.current_buffer. When the next frame arrived,on_process()immediately queued that previouspw_bufferback to PipeWire.Duplicating a DMA-BUF fd keeps the allocation alive; it does not prevent the producer from reusing and overwriting the buffer. Because GL/CUDA conversion consumes the imported image later on another thread, KWin could begin rendering new content into the same allocation before Sunshine had completed the read. That produces coherent flashes of unrelated window content rather than codec corruption.
Changes
stream_data.current_buffer, preventing the next process callback from returning it early.reset()invokes it as a fallback when conversion exits early.Validation
25c06d7.git diff --checkafter rebasing onto3cba9ba.Scope
This does not change the encoder and does not attempt to fix KMS capture. LizardByte#3235 describes a similar visual symptom, but that report used KMS and is referenced only for context.