Skip to content

fix: disable WebRTCPipeWireCapturer on XWayland; add Wayland audit and ADR-016#2225

Closed
IsmaelMartinez wants to merge 7 commits intomainfrom
claude/analyze-wayland-electron-6LeeT
Closed

fix: disable WebRTCPipeWireCapturer on XWayland; add Wayland audit and ADR-016#2225
IsmaelMartinez wants to merge 7 commits intomainfrom
claude/analyze-wayland-electron-6LeeT

Conversation

@IsmaelMartinez
Copy link
Owner

@IsmaelMartinez IsmaelMartinez commented Feb 23, 2026

Summary

The Fix (Option F)

Chromium's DesktopCapturer::IsRunningUnderWayland() selects the PipeWire capture backend by checking XDG_SESSION_TYPE and WAYLAND_DISPLAY — with zero coupling to --ozone-platform. Under XWayland, both env vars remain set, so PipeWire is selected and xdg-desktop-portal authorization is required before desktopCapturer.getSources() returns any sources. Without --use-fake-ui-for-media-stream providing that auth, getSources() returns empty silently — causing the empty screen picker in #2217.

Explicitly disabling WebRTCPipeWireCapturer when isX11Forced short-circuits the PipeWire backend selection before the env var check. This forces the X11 screengrab path on XWayland, making getSources() return results without portal authorization. Camera and mic permissions are unaffected — this flag only controls the screen capture backend, not the getUserMedia() permission path.

app/startup/commandLine.js changes:

  • Removes the dead-code WebRTCPipeWireCapturer enable block (default since Chromium 110, expired at M120)
  • When isX11Forced: disables WebRTCPipeWireCapturer, merged into the existing disable-features value (preserving HardwareMediaKeyHandling)
  • When native Wayland: keeps --use-fake-ui-for-media-stream as before

Verified: app.commandLine.appendSwitch writes to a map with last-write-wins semantics. InitializeFeatureList() reads the map once at startup. The read-merge-write pattern correctly combines both features into a single disable-features value.

Note: This is theoretically sound (confirmed via Chromium source) but needs validation on real XWayland hardware. Treating as a candidate fix pending test.

Documentation

  • wayland-optimizations-audit.md: merges the previous separate research doc into a single document covering the flag inventory, root cause analysis (with IsRunningUnderWayland() source), historical complications, options A–F, and next steps
  • ADR-016: records the rationale for each Wayland flag — XWayland forcing, GPU auto-disable, WebRTCPipeWireCapturer disable on XWayland, --use-fake-ui-for-media-stream for native Wayland only, HardwareMediaKeyHandling disable

Related Issues

Fixes #2217 (screen sharing broken on XWayland — pending hardware validation)
Preserves fix for #2169 (camera broken on XWayland)
Related: #2221, #2222, #2204, #2107

Known Remaining Issues

🤖 Generated with Claude Code

Comprehensive analysis of all Wayland-specific workarounds in the
codebase, their continued necessity given Electron 38-40 changes,
and per-flag recommendations. Key finding: WebRTCPipeWireCapturer
flag is redundant (default since Chromium 110) and can be removed.

https://claude.ai/code/session_01VsfQXFDXjgZA6tPnXviwjC
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @IsmaelMartinez, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces detailed research findings regarding the project's Wayland-specific workarounds. It evaluates the continued necessity of several flags, identifies one for immediate removal due to redundancy, and outlines a strategic path for future native Wayland migration as upstream issues are resolved. The audit also provides insights into the camera/mic crash reported in Issue #2221, suggesting it may not be directly related to Wayland.

Highlights

  • Wayland Workarounds Audit: A comprehensive audit of existing Wayland-specific flags and workarounds was conducted, assessing their necessity and providing recommendations for simplification and future migration.
  • Redundant Flag Identified: The --enable-features=WebRTCPipeWireCapturer flag was found to be redundant as the feature has been enabled by default in Chromium since version 110, recommending its immediate removal.
  • XWayland Forcing Necessity: The --ozone-platform=x11 flag, which forces XWayland, remains necessary due to ongoing upstream GPU acceleration issues on native Wayland across various hardware and virtualized environments.
  • Issue [Bug]: Crash when using camera or microphone #2221 Analysis: Research suggests that the camera/mic crash reported in Issue [Bug]: Crash when using camera or microphone #2221 is likely not Wayland-specific, as it occurs on both native Wayland and XWayland, pointing to a potential root cause elsewhere.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • docs-site/docs/development/research/README.md
    • Added a new entry for the "Wayland Optimizations Audit" document to the "Ready for Implementation" section.
    • Included a summary of the audit's key findings and status.
  • docs-site/docs/development/research/wayland-optimizations-audit.md
    • Created a new document providing a detailed audit of seven Wayland-specific flags and workarounds.
    • Analyzed each flag's purpose, history, current necessity, and provided recommendations for retention or removal.
    • Identified WebRTCPipeWireCapturer as redundant and --ozone-platform=x11 as still necessary.
    • Discussed the relationship between workarounds and Issue [Bug]: Crash when using camera or microphone #2221, suggesting it's not Wayland-specific.
    • Outlined immediate cleanup actions and a medium-term migration strategy.
Activity
  • A comprehensive audit of Wayland optimizations and workarounds has been completed.
  • Immediate cleanup actions, such as removing a redundant flag, have been identified.
  • Recommendations for medium-term migration to native Wayland have been documented, pending upstream stabilization.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

✅ Changelog entry generated and committed to this PR:

docs: add Wayland optimizations audit and research findings - by @IsmaelMartinez (#2225)

The file .changelog/pr-2225.txt will be included when you merge this PR.

You can edit it directly in this PR if needed.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

📦 PR Build Artifacts

Build successful! Download artifacts:

🐧 Linux

x86_64 (435.66 MB) - Contains: .deb, .rpm, .tar.gz, .AppImage

arm64 (426.87 MB) - Contains: .deb, .rpm, .tar.gz, .AppImage

armv7l (404.93 MB) - Contains: .deb, .rpm, .tar.gz, .AppImage

🍎 macOS

x86_64 (125.28 MB) - Contains: .dmg

🪟 Windows

x86_64 (105.74 MB) - Contains: .exe installer


📝 Note: Snap packages (.snap) are built in a separate workflow

View workflow run

🕐 Last updated: 2026-02-24 00:25 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Feb 23, 2026

📦 PR Snap Build Artifacts

Snap builds successful! Download artifacts:

🐧 Linux Snap Packages

x86_64 (107.69 MB)

arm64 (104.61 MB)

armv7l (98.83 MB)


📝 Note: Other package formats (.deb, .rpm, .AppImage, .dmg, .exe) are built in the main workflow

View workflow run

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a comprehensive audit of Wayland optimizations and workarounds, documenting their necessity and providing recommendations. It also updates the README.md to include this new research document. The audit identifies an immediate cleanup opportunity by removing a redundant WebRTCPipeWireCapturer flag and outlines a medium-term migration path for native Wayland support. The documentation is well-structured and provides valuable insights into the project's Wayland strategy.

IsmaelMartinez and others added 5 commits February 23, 2026 22:03
Cross-references #2217 (screen sharing) and #2169 (camera) as a direct
conflict that cannot be solved by toggling --use-fake-ui-for-media-stream.
Adds research for session.setDisplayMediaRequestHandler() as the proper
fix. Also links #2222 (microphone), #2204 (thumbnail), and #2107 (MQTT)
as related open issues affected by the same underlying flag conflict.
…tigation

Deep investigation revealed the handler is already implemented at
mainAppWindow/index.js:264. Screen sharing still breaks on XWayland
without --use-fake-ui-for-media-stream because desktopCapturer.getSources()
returns empty — the flag provides PipeWire portal auth that getSources()
needs, not just dialog suppression.

Root cause of #2169 clarified: permission persistence corruption across
sessions (first launch works after clearing Local Storage, subsequent
launches fail), not a constant GPU failure. These two issues directly
contradict each other — no known API resolves both simultaneously.

Updated status from "Ready for Implementation" to investigation-needed.
Added historical complications, 5 options analysis, and concrete next steps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Key corrections from multi-agent review:

- Confirm root cause via Chromium source: DesktopCapturer::IsRunningUnderWayland()
  checks XDG_SESSION_TYPE/WAYLAND_DISPLAY independently of --ozone-platform
- Add Option F: --disable-features=WebRTCPipeWireCapturer when isX11Forced as
  the most targeted fix (short-circuits PipeWire before env var check)
- Fix investigation step 1 location: getSources() failure is in service.js
  #handleGetDesktopCapturerSources, not handleScreenSourceSelection
- Document sendScreenSharingStarted(null) preload guard bug dropping IPC events
- Fix audit Near-Term Priority: setDisplayMediaRequestHandler already exists;
  --disable-features=WebRTCPipeWireCapturer is the correct next step
- Soften #2222 characterization to require debug logs rather than speculation
- Note PR #2207 (redundant getSources() removal) as correct complementary fix
- Add Chromium source and Electron upstream issue references

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Combines set-display-media-request-handler-research.md into
wayland-optimizations-audit.md for a single cohesive document covering
both the per-flag audit and the deep dive into the #2169 vs #2217 conflict.

The two files cross-referenced each other constantly — merging removes
the split context and makes the investigation flow naturally from the
flag inventory through root cause analysis to options and next steps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…#2217)

DesktopCapturer::IsRunningUnderWayland() in Chromium selects the PipeWire
capture backend based on XDG_SESSION_TYPE/WAYLAND_DISPLAY independently of
--ozone-platform. Under XWayland both env vars remain set, so PipeWire is
selected and portal auth is required before getSources() returns sources.
Without --use-fake-ui-for-media-stream the auth never happens and getSources()
returns empty — causing the empty screen picker in #2217.

Explicitly disabling WebRTCPipeWireCapturer when isX11Forced short-circuits
the PipeWire backend selection before the env var check, forcing the X11
screengrab path. Camera/mic permissions are unaffected. Removes the dead-code
WebRTCPipeWireCapturer enable block (default since Chromium 110, expired M120).

Also adds ADR-016 documenting all Wayland flag decisions and their rationale.

Fixes #2217
Ref: #2169, ADR-016

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

@IsmaelMartinez IsmaelMartinez changed the title docs: add Wayland optimizations audit and research findings fix: disable WebRTCPipeWireCapturer on XWayland; add Wayland audit and ADR-016 Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

[Bug]: Screen sharing broken

2 participants