Fixes Direct3D capture issues on Windows#1144
Conversation
Addresses several issues related to Direct3D capture on Windows: - Ensures the GraphicsCaptureItem is created on the capture thread to avoid COM threading problems. - Propagates encoder setup errors back to the main thread. - Improves error handling and logging in the capture thread. - Shares the D3D device with the encoder to avoid device mismatch.
WalkthroughUpdates improve Windows recording components. Output pipeline now logs encoder readiness/setup failures as errors and propagates thread termination errors. Screen capture refactors to use DisplayId, creating GraphicsCaptureItem on the capture thread, updating setup/start flows, and expanding logging and error propagation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant VideoSource as VideoSource::setup
participant CapThread as Capture Thread
participant WinAPI as Windows GraphicsCapture/Direct3D
App->>VideoSource: setup(VideoSourceConfig{ display_id, ... })
VideoSource->>CapThread: spawn + init channels
Note over CapThread: Create GraphicsCaptureItem on capture thread
CapThread->>WinAPI: Display::from_id(display_id)
alt item created
CapThread->>WinAPI: Create GraphicsCapture capturer + D3D11 resources
CapThread-->>VideoSource: send ready()
CapThread->>CapThread: start capture loop
else error creating item/init
CapThread-->>VideoSource: send error()
CapThread-->>CapThread: terminate thread
end
Note over VideoSource: Await ready/error
VideoSource-->>App: return Ok/Err
rect rgba(255,230,230,0.4)
Note right of VideoSource: Output pipeline change
App->>VideoSource: start encoder
VideoSource-->>App: error! log on readiness/send failure<br/>propagate thread termination errors
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (4)crates/**/src/**/*.rs📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx,js,jsx,rs}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.rs📄 CodeRabbit inference engine (AGENTS.md)
Files:
crates/*/src/**/*📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧬 Code graph analysis (1)crates/recording/src/sources/screen_capture/windows.rs (1)
🔇 Additional comments (3)
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 |
Addresses several issues related to Direct3D capture on Windows:
Summary by CodeRabbit
Bug Fixes
Refactor
Chores