Portal + VAAPI: streaming fails, encoder loops with EGL_BAD_PARAMETER

オープン
#6,114 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, linux
領域
backend

調査の方向性

Start with build_format_parameter() and make_avcodec_encode_device() in the capture and encoder negotiation paths, then trace how the portal stream reports its negotiated buffer type to the encode thread. The report identifies an empty modifier list, shared memory negotiation, and repeated VAAPI import failures; check those paths against the attached logs and probe notes. Done means portal capture with VAAPI streams frames whether DMA-BUF is negotiated or memory buffers are used.

索引モデルが issue の本文から書いたものです。

説明

Is there an existing issue for this?
  • I have searched the existing issues
Is your issue described in the documentation?
  • I have read the documentation
Is your issue present in the latest beta/pre-release?

This issue is present in the latest pre-release

Describe the Bug

I can't stream on this machine when both capture = portal and encoder = vaapi
are set. The client connects, but not a single frame arrives, and the log keeps
printing the same four lines while the connection is up:

[21:31:24.502] [pipewire] using memory buffers
[21:31:24.515] Creating encoder [hevc_vaapi]
[21:31:24.537] Error: Couldn't import RGB Image: 0000300C
[21:31:24.537] Error: Could not convert image

0000300C is EGL_BAD_PARAMETER, roughly once per frame.

Configuration Result
capture = portal, encoder = software (libx264) works
capture = kms, encoder = vaapi, kernel 7.3.4 works
capture = portal, encoder = vaapi fails

So the capture path and the encoder each work on their own; only this pairing
fails.

The failure comes from five steps chained together. Each step only holds under its
own precondition, and each one only accounts for the change that precondition
brings.

First, this machine reports no modifiers. I ran eglQueryDmaBufModifiersEXT for
AR24/XR24 on every real GPU path: the Wayland platform, the card1 EGL device, GBM
on renderD128, and GBM on card1. All returned 0. Only the software EGL device
reports LINEAR. That is not a fault in itself; it just means there is no layout
label to announce, and the CPU copy path still works. Conversely, if the system
did report modifiers, this step and the following ones would not apply.

Second, with an empty list the modifier property never goes out at all. When
Sunshine builds the request, build_format_parameter() only writes the
SPA_FORMAT_VIDEO_modifier field if n_modifiers > 0; with an empty list that
whole branch is skipped. So the request that reaches the compositor has no
modifier entry in it whatsoever. Still nothing broken at this point.

Third, when that property is missing, KWin 6.8 only offers shared memory. Its
onStreamParamChanged() clears the DMA-BUF state when it cannot find the field. I
did not verify other compositors. This is where the problem starts: "not
specified" is read as "not needed", so the stream falls back to shared memory. On
its own this step is only a downgrade, slower but not broken.

Fourth, the encoder is chosen without looking at the negotiation result.
make_avcodec_encode_device() picks the vram path from n_dmabuf_infos > 0, and
that number counts formats, not modifiers. It stays above zero even after the
stream negotiated memory buffers. This is where it actually breaks: the encoder
assumes DMA-BUF while the frames have no fd behind them, so every import throws
EGL_BAD_PARAMETER. If the stream had been on DMA-BUF all along, this step alone
would be harmless.

Fifth, nothing degrades after a failed import. convert() returns an error, the
encode thread exits, the session restarts, and the same choice is made again. A
single failed import is enough to take the whole stream down for good, and the
client never gets a frame.

Expected Behavior

capture = portal with encoder = vaapi should produce video. Either path is
fine: DMA-BUF if the compositor offers it, memory copy otherwise. If an import
does fail, the stream should fall back to the memory copy instead of exiting the
encode thread and rebuilding the session.

Additional Context

Full logs, the EGL probe programs I used, and the notes from this investigation
are in one place, one directory per date:
https://github.com/aningQwQ/backup/tree/main/sunshine/2026-11-16

There's also a branch where I tried a fix, mostly so you can see what I mean:
https://github.com/aningQwQ/Sunshine/tree/2026-11-16
Built from that, the same machine logs using DMA-BUF buffers and no import
failures over an 8 minute session.

That fix came out of an AI-assisted session and I can't review the code myself,
so I'm not opening a PR.

One more thing I noticed while looking at this: a pw-dump taken during streaming
shows KWin announcing two formats, one with a modifier and one without. Since the
client request carries no modifier property, the negotiation lands on the second
one.

Host Operating System

Linux

Operating System Version

Linux xuyingjun-cachyos 7.3.4-1-cachyos #1 SMP PREEMPT_DYNAMIC Fri, 13 Nov 2026 19:45:18 +0000 x86_64 GNU/Linux

Architecture

amd64/x86_64

Package

Linux - AUR (Third Party)

GPU Type

AMD

GPU Model

Radeon RX 590 GME (Polaris 10)

GPU Driver/Mesa Version

GPU Driver/Mesa Version: Mesa 26.2.6-arch3.1, LLVM 23

Capture Method

XDG Portal Grab (FreeBSD/Linux)

Apps

Log output
https://github.com/aningQwQ/backup/tree/main/sunshine/2026-11-16
Online logs

https://github.com/aningQwQ/backup/tree/main/sunshine/2026-11-16

主要言語
C++
スター
43k
フォーク
2.4k
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

LizardByte/Sunshine のほかの issue

LizardByte/Sunshine の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。