Attach to the X server on the active VT and keep a retryable DXGI frame from tearing down the capturer

Claude-Session: https://claude.ai/code/session_01QKDYfH4WKLbpNQHccpVo3P
This commit is contained in:
Viktor Liu
2026-08-29 16:59:05 +02:00
parent 15d6e3bea9
commit fecd7cfff5
17 changed files with 476 additions and 85 deletions
+11
View File
@@ -3,6 +3,7 @@
package server
import (
"errors"
"fmt"
"image"
"runtime"
@@ -435,6 +436,11 @@ type frameCapturer interface {
close()
}
// errFrameNotReady is the capture error that means "healthy, but nothing to
// hand out yet". The worker answers the request with it and keeps the
// capturer, where any other error tears the capturer down and rebuilds it.
var errFrameNotReady = errors.New("no frame captured yet")
// captureWorker owns the worker goroutine's mutable state. Extracted into a
// struct so the request/desktop/init logic can live on small methods and the
// outer worker() stays a thin loop.
@@ -475,6 +481,11 @@ func (w *captureWorker) serveRequest(req captureReq) {
return
}
img, err := fc.capture()
if errors.Is(err, errFrameNotReady) {
log.Tracef("capture: %v", err)
req.reply <- captureReply{err: err}
return
}
if err != nil {
log.Debugf("capture: %v", err)
w.closeCapturer()