Skip to content

fix(linux): remove unnecessary screen capture from audio loopback handler - #1926

Merged
kgarner7 merged 1 commit into
jeffvli:developmentfrom
noctuum:fix/wayland-screen-share-dialog
Apr 8, 2026
Merged

kgarner7 merged 1 commit into
jeffvli:developmentfrom
noctuum:fix/wayland-screen-share-dialog

Conversation

@noctuum

@noctuum noctuum commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Screenshot_20260408_032622

On Wayland, Feishin shows an xdg-desktop-portal "Share screen" dialog on every launch. This happens because setDisplayMediaRequestHandler calls desktopCapturer.getSources({ types: ['screen'] }), which creates a new ScreenCast session each time. Electron does not persist PipeWire restore tokens across desktopCapturer sessions, so the dialog cannot be suppressed.

The video source provided by the handler is unused — the renderer requests video: false (since ef129e4) and only consumes audio tracks for the visualizer.

Changes

  • Removed desktopCapturer.getSources() call from the display media handler
  • Simplified handler to callback({ audio: 'loopback' })
  • Removed unused desktopCapturer import

Alternatives considered

  • Pass video + strip tracks in renderer: Does not solve the problem — desktopCapturer.getSources() still triggers the portal dialog
  • Platform-conditional logic (skip video on Wayland only): Adds complexity for no benefit since video is unused on all platforms
  • PipeWire restore tokens: Electron's desktopCapturer.getSources() API does not support storing or re-presenting restore tokens — this is an Electron limitation, not a portal bug

Testing

  • Arch Linux, KDE Plasma 6, Wayland, Electron 39
  • Verified: no portal dialog on launch
  • Verified: visualizer works with system audio loopback
  • Verified: reverting to unpatched build reproduces the dialog

…a handler

The setDisplayMediaRequestHandler was calling desktopCapturer.getSources()
to provide a video source that the renderer never uses (it requests
video: false and only consumes audio tracks). On Wayland, this created a
new xdg-desktop-portal ScreenCast session on every launch, showing an
unavoidable screen share dialog because Electron does not persist
PipeWire restore tokens across desktopCapturer sessions.

Simplified the handler to return only { audio: 'loopback' }, which
captures system audio via PipeWire/PulseAudio monitor source without
any portal interaction.
@vercel

vercel Bot commented Apr 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
feishin Ready Ready Preview, Comment Apr 7, 2026 9:58pm

@kgarner7 kgarner7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This capture is necessary to work on macOS and Linux, so this PR is incorrect.
There is a prompt about whether to enable audio capture in Feishin first, although it looks like that can't be toggled from settings.
Linux audio capture doesn't seem to be working, so a better option might be to just disable it.

@noctuum

noctuum commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

@kgarner7 Thanks for the review!

System audio loopback is a brand-new feature added in v1.11.0 (commits 94886a2, ef129e4, 3f300c4 — all from April 5). It does work on Linux — I've tested it on Arch Linux with KDE Plasma 6, Wayland, PipeWire, and Electron 39. The visualizer captures system audio correctly with just { audio: 'loopback' }.

The key observation is that the maintainer already set video: false in the renderer (ef129e4), so the video source provided by the handler is explicitly unused. On Wayland, the desktopCapturer.getSources() call triggers an xdg-desktop-portal ScreenCast dialog on every launch because Electron doesn't persist PipeWire restore tokens — this PR simply removes that unnecessary call to match the renderer's intent.

I don't have access to a Mac, so I can't verify macOS behavior. If macOS requires the video source for Chromium's internal audio capture pipeline, I'm happy to make this conditional — skipping desktopCapturer.getSources() only on Linux where PipeWire/PulseAudio loopback works independently of screen capture.

@kgarner7

kgarner7 commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

I have no idea how you got it to work on Linux, because I can confirm on my own setup it's just a flatline. Nevertheless, I do see that with just audio loopback macos (probably; at least the visualizer is doing a silly) and windows are working, so I guess this is good enough.

@kgarner7
kgarner7 merged commit 167b42d into jeffvli:development Apr 8, 2026
6 checks passed
@noctuum
noctuum deleted the fix/wayland-screen-share-dialog branch April 8, 2026 02:19
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 6, 2026

This branch was successfully deployed

1 active deployment
Preview — 6adb29bc Deployed Apr 7, 2026 by vercel[bot]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants