Skip to content

Commit 376260f

Browse files
jeanfbritoclaude
andauthored
feat: Enhance Linux support for screen sharing and dependencies (#3162)
* feat: Enhance Linux support for screen sharing and dependencies - Added `xdg-desktop-portal` and `xdg-desktop-portal-gtk` as recommended dependencies in the Electron builder configuration for improved screen sharing functionality on Linux. - Removed the ozone platform switch for `x11` in the Electron startup process and enabled PipeWire screen capture support for Wayland environments. - Updated the display media request handler to utilize system picker for better user experience during screen sharing. * chore: Bump version to 4.10.2 in package.json * feat(videoCall): Implement screen sharing request handling and cleanup logic - Added a timeout mechanism for screen sharing requests to prevent orphaned listeners. - Introduced cleanup functions for screen sharing listeners and request states to enhance resource management. - Improved IPC handling for screen sharing source responses, ensuring proper request tracking and error handling. - Enhanced user experience by preventing concurrent screen sharing requests and managing listener cleanup effectively. * fix(videoCall): Improve screen sharing timeout handling and listener cleanup - Added validation to ensure the screen sharing timeout is only processed for the current request, preventing double-invocation. - Enhanced cleanup logic to clear timeout references and invoke callbacks appropriately, improving resource management and user experience during screen sharing sessions. * fix(videoCall): Refactor screen sharing listener cleanup and request completion handling - Introduced `removeScreenSharingListenerOnly` to streamline listener removal and timeout clearing without altering the pending request state. - Added `markScreenSharingComplete` to reset request states, allowing new screen sharing requests after completion. - Enhanced existing cleanup logic to improve resource management and prevent concurrent screen sharing requests. * feat(gpuFallback): Implement GPU crash detection and fallback mode for Linux - Added a GPU crash handler to automatically switch to X11 mode if the GPU process crashes during startup. - Introduced a persistent fallback mode setting to remember the user's choice across sessions. - Enhanced the settings UI to allow users to control the display server mode, including options for auto-detect, force X11, or disable GPU. - Updated the application to handle GPU fallback mode changes dynamically, improving user experience and stability on Linux systems. * fix(app): Adjust crash count condition and preserve command-line arguments on relaunch - Updated the crash detection logic to trigger fallback mode after exceeding the maximum crash count. - Enhanced the relaunch functionality to preserve command-line arguments, ensuring user inputs are retained during application restarts. * feat: Enhance Linux display server support and crash handling - Added Wayland support to the Electron builder configuration, allowing for improved compatibility with modern Linux environments. - Updated documentation to reflect auto-detection of display servers for Snap packages, enhancing user clarity. - Refactored crash detection logic to use a more descriptive variable name and improved logging for better debugging during GPU fallback scenarios. * refactor(app): Streamline GPU crash handling and fallback logic - Simplified the GPU crash detection process by consolidating logic for tracking crash counts and managing fallback mode. - Improved logging for better visibility during relaunch scenarios. - Ensured that the application preserves command-line arguments when relaunching after a GPU crash. * docs: Update Linux display server documentation and improve GPU crash recovery details - Clarified the automatic GPU crash detection and recovery process in the documentation. - Removed version-specific language for GPU crash recovery to streamline information. - Enhanced the logging section with standard Chromium flags for better debugging. * feat(scripts): Add installation and testing scripts for Linux - Introduced `install-volta.sh` to automate the installation of Volta, ensuring node.js and npm are available for building the project. - Added `linux-test-deb.sh` for building, installing, and running the Rocket.Chat Desktop .deb package, with options to skip build, install, or run steps. - Created a README.md to document the usage and functionality of the new scripts, enhancing developer experience and automation for testing on Linux. * refactor(scripts): Improve error handling in installation and dependency management - Updated `install-volta.sh` to handle installation errors more gracefully by checking the success of the Volta installation command. - Enhanced `linux-test-deb.sh` to streamline dependency installation checks and provide clearer error messages if installation fails. - Refactored the package installation logic to handle dependency issues more effectively, ensuring smoother installation processes. * feat(linux): Enhance Wayland and X11 support for GPU handling - Implemented auto-detection of Wayland sessions and added logic to relaunch the app with X11 fallback for stability. - Updated GPU fallback mode to include 'wayland' as a valid option, allowing users to specify their preferred display server. - Improved logging for GPU crash handling and display server mode selection, enhancing debugging and user experience on Linux. - Adjusted screen sharing request handling to utilize XDG portal on Wayland sessions, improving compatibility with modern desktop environments. * feat(videoCall): Introduce screen picker functionality for enhanced screen sharing - Implemented a new screen picker system to handle display media requests, improving user experience during screen sharing. - Created internal and portal picker providers to support different environments, including Linux Wayland and X11. - Enhanced IPC handling for screen sharing requests, ensuring proper state management and preventing concurrent requests. - Added initialization and cleanup logic for the screen picker, streamlining resource management and improving performance. * refactor(videoCall): Improve screen sharing request handling and listener management - Refactored the internal picker handler to enhance state management during screen sharing requests, preventing concurrent requests and ensuring proper cleanup. - Improved error handling for screen sharing source validation, including better logging for unavailable sources and request timeouts. - Streamlined the listener setup and removal process, enhancing resource management and overall performance during screen sharing operations. * refactor(videoCall): Enhance webview handler setup and error management - Refactored the setup of webview handlers to use lazy loading for the screen picker module, improving performance and preventing blocking during webview initialization. - Improved error handling in the display media request handler, ensuring that errors are logged without disrupting the webview loading process. - Updated the internal picker provider to streamline the handling of display media requests, particularly for Linux environments. * refactor(gpuFallback): Extend valid fallback modes and improve type safety - Updated the GPU fallback mode validation to include 'wayland' as a valid option, enhancing compatibility with modern Linux environments. - Improved type safety in the reducer by refining the type checks for fallback modes, ensuring better error handling and maintainability. * refactor(gpuFallback): Improve fallback mode handling in reducer - Updated the GPU fallback mode reducer to return the current state if the provided fallback mode is invalid, enhancing stability and preventing unintended state changes. - This change ensures that only valid fallback modes are accepted, improving overall type safety and error handling. * refactor(videoCall): Update display media request handling for improved platform compatibility - Enhanced comments in the IPC and PortalPickerProvider files to clarify the behavior of the display media request handler across different platforms, particularly focusing on macOS and Linux/Wayland. - Adjusted the handling of the XDG portal picker to ensure it returns a valid source or an empty array, improving robustness in source selection during screen sharing. * refactor(config): Clean up whitespace and improve logging consistency - Removed unnecessary whitespace in rollup configuration and video call window files for better readability. - Consolidated console log statements in the app setup to enhance clarity and maintain consistency in logging format. - Improved import organization in screen picker files to follow a more structured format. * fix(build): Update electron-builder command to include appimage target - Modified the build command in the pull request workflow to include 'appimage' as a target alongside 'snap' and 'deb', enhancing the packaging options for Linux distributions. * feat(build): Add AppImage support to pull request workflow - Updated the pull request build workflow to include the AppImage target in the S3 upload command, expanding the packaging options for Linux distributions. * fix(build): Correct AppImage file extension in pull request workflow - Updated the file extension for AppImage in the S3 upload command from '.AppImage' to '.appimage' to ensure proper handling of the file format during the build process. * fix(build): Add AppImage pattern to pull request workflow file matching - Updated the file matching patterns in the pull request build workflow to include the AppImage file extension, ensuring proper identification and handling of AppImage artifacts during the build process. * feat(scripts): Add Linux AppImage testing script - Introduced a new script for testing the Rocket.Chat Linux AppImage, which includes steps for building, making the AppImage executable, and running it. - The script provides options to skip build, installation, and execution, along with informative logging for each step. - Enhanced the relaunch functionality in the app to support AppImage, ensuring reliable relaunch behavior. * refactor(gpuFallback): Simplify GPU fallback handling and improve logging - Removed unnecessary session type checks for Wayland, streamlining the logic for determining X11 fallback needs. - Updated logging messages for clarity when relaunching the app with X11. - Adjusted the order of GPU crash handler setup to catch early failures more effectively. * refactor(gpuFallback): Enhance Wayland handling and logging for X11 fallback - Introduced a check for Wayland sessions in handleLinuxDisplayServer to default to XWayland for stability, addressing potential GPU issues on virtual machines. - Updated logging messages to clarify the use of XWayland when a Wayland session is detected, improving user guidance on display server settings. - Removed redundant Wayland session checks from performElectronStartup, streamlining the GPU fallback logic. * feat(wayland): Enable native Wayland support by default Use native Wayland when available instead of forcing X11 fallback. The GPU crash handler will automatically switch to X11 if issues occur. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Address PR review comments - Remove X11 forcing on Wayland in linux-test-deb.sh (use native Wayland) - Fix console.log formatting with JSON.stringify in src/main.ts - Fix misleading success message in test scripts when app exits early - Remove unnecessary `as any` type assertion in InternalPickerProvider.ts * fix(linux): Enforce X11 mode on Wayland sessions Always use X11 (XWayland) on Wayland sessions for stability. The app automatically relaunches with --ozone-platform=x11 when a Wayland session is detected. * feat(wayland): Enable native Wayland support by default Use native Wayland when available instead of forcing X11 fallback. The GPU crash handler will automatically switch to X11 if issues occur. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(linux): Add proactive GPU detection with X11 fallback - Remove sentinel file system (crash counting, timing windows) - Add gpu-info-update listener to detect GPU issues early - Check gpu_compositing and webgl status for disabled/unavailable states - Relaunch with --disable-gpu --ozone-platform=x11 when GPU is broken - Simplify crash handler to immediately trigger fallback on GPU crash * fix(ci): Fix AppImage upload and PR comment updates - Fix case sensitivity: rocketchat-*.appimage → rocketchat-*.AppImage (AWS CLI on Linux is case-sensitive, file wasn't being uploaded) - Fix sticky comment header to use simple identifier instead of markdown - Remove redundant recreate/append flags (defaults work correctly) --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 6298e8c commit 376260f

File tree

18 files changed

+1570
-61
lines changed

18 files changed

+1570
-61
lines changed

.github/workflows/pull-request-build.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ jobs:
522522

523523
- name: Build Ubuntu Package
524524
if: ${{ matrix.build-target == 'linux' }}
525-
run: yarn electron-builder --publish never --linux snap deb
525+
run: yarn electron-builder --publish never --linux snap deb appimage
526526

527527
- name: Find Snap File
528528
id: find_snap
@@ -586,6 +586,7 @@ jobs:
586586
--endpoint-url=https://s3.us-east-1.wasabisys.com \
587587
--exclude "*" \
588588
--include "rocketchat-*.snap" \
589+
--include "rocketchat-*.AppImage" \
589590
--include "rocketchat-*.deb"
590591
env:
591592
AWS_ACCESS_KEY_ID: ${{ secrets.WASABI_ACCESS_KEY_ID }}
@@ -601,7 +602,7 @@ jobs:
601602
const path = require('path');
602603
const distDir = path.join(process.cwd(), 'dist');
603604
const files = fs.readdirSync(distDir);
604-
const patterns = [/rocketchat-.*\.dmg$/, /rocketchat-.*\.pkg$/, /rocketchat-.*\.exe$/, /rocketchat-.*\.snap$/, /rocketchat-.*\.deb$/];
605+
const patterns = [/rocketchat-.*\.dmg$/, /rocketchat-.*\.pkg$/, /rocketchat-.*\.exe$/, /rocketchat-.*\.snap$/, /rocketchat-.*\.deb$/, /rocketchat-.*\.appimage$/i];
605606
let artifactUrls = '';
606607
for (const file of files) {
607608
if (patterns.some(pattern => pattern.test(file))) {
@@ -616,9 +617,7 @@ jobs:
616617
uses: marocchino/sticky-pull-request-comment@v2
617618
with:
618619
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
620+
header: ${{ runner.os }}-installer
619621
message: |
620622
### ${{ runner.os }} installer download
621623
${{ steps.get-artifact-urls.outputs.artifact_urls }}
622-
header: '### ${{ runner.os }} installer download'
623-
recreate: true
624-
append: false

docs/linux-display-server.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
# Linux Display Server Configuration
2+
3+
Rocket.Chat Desktop uses native Wayland by default when available, with automatic GPU crash recovery.
4+
5+
## Default Behavior
6+
7+
| Package Type | Display Server | Notes |
8+
|--------------|---------------|-------|
9+
| **deb/rpm** | Native (Wayland/X11) | Uses system default |
10+
| **Snap** | Native (Wayland/X11) | Uses system default |
11+
| **AppImage** | Native (Wayland/X11) | Uses system default |
12+
13+
## Automatic GPU Crash Recovery
14+
15+
Rocket.Chat Desktop includes automatic GPU crash detection and recovery:
16+
17+
1. **Crash Detection**: If the GPU process crashes during startup (e.g., due to incompatible drivers), the app detects this automatically.
18+
19+
2. **Automatic Fallback**: After detecting repeated crashes, the app relaunches with GPU acceleration disabled.
20+
21+
3. **Recovery**: Once GPU is disabled, the app will continue to run with software rendering.
22+
23+
## Wayland Support
24+
25+
Rocket.Chat Desktop includes native Wayland support with:
26+
- PipeWire screen capture for video calls
27+
- Native OS screen picker integration
28+
- Hardware acceleration
29+
30+
### Requirements for Wayland
31+
- `xdg-desktop-portal` (recommended, auto-suggested by deb/rpm packages)
32+
- `xdg-desktop-portal-gtk` or desktop-specific portal backend
33+
- PipeWire for screen sharing
34+
- Modern GPU drivers
35+
36+
## Known Issues
37+
38+
### Virtual Machines
39+
VMs with paravirtual graphics (QXL, VirtualBox, VMware) may have issues with GPU acceleration.
40+
41+
**Symptoms:**
42+
```text
43+
ERROR:viz_main_impl.cc:189] Exiting GPU process due to errors during initialization
44+
```
45+
46+
**Automatic Recovery:** The app automatically detects this crash and disables GPU acceleration. You should see the app restart and work normally after the crashes.
47+
48+
**Manual Solution:** If auto-recovery doesn't work, disable GPU:
49+
```bash
50+
rocketchat-desktop --disable-gpu
51+
```
52+
53+
### Screen Sharing Not Working on Wayland
54+
55+
If screen sharing doesn't work on Wayland:
56+
57+
1. Install portal dependencies:
58+
```bash
59+
# Ubuntu/Debian
60+
sudo apt install xdg-desktop-portal xdg-desktop-portal-gtk pipewire
61+
62+
# Fedora
63+
sudo dnf install xdg-desktop-portal xdg-desktop-portal-gtk pipewire
64+
65+
# Arch
66+
sudo pacman -S xdg-desktop-portal xdg-desktop-portal-gtk pipewire
67+
```
68+
69+
2. Restart your session or reboot
70+
71+
3. Verify PipeWire is running:
72+
```bash
73+
systemctl --user status pipewire
74+
```
75+
76+
## Manual Override
77+
78+
You can force a specific display server:
79+
80+
```bash
81+
# Force X11
82+
rocketchat-desktop --ozone-platform=x11
83+
84+
# Force Wayland
85+
rocketchat-desktop --ozone-platform=wayland
86+
87+
# Disable GPU acceleration
88+
rocketchat-desktop --disable-gpu
89+
```
90+
91+
## Troubleshooting
92+
93+
### Check Your Display Server
94+
```bash
95+
echo $XDG_SESSION_TYPE
96+
# Output: "wayland" or "x11"
97+
```
98+
99+
### Check GPU Support
100+
```bash
101+
# Check graphics card
102+
lspci | grep -i vga
103+
104+
# Check VA-API support (hardware video decode)
105+
vainfo
106+
```
107+
108+
### Enable Verbose Logging
109+
110+
These are standard Chromium flags that enable detailed logging output:
111+
112+
```bash
113+
rocketchat-desktop --enable-logging --v=1
114+
```
115+
116+
### Disable GPU Acceleration (last resort)
117+
```bash
118+
rocketchat-desktop --disable-gpu
119+
```
120+
121+
## Best Practices
122+
123+
- **Real Hardware + Wayland**: Use default for best experience
124+
- **VM**: The app will auto-detect and disable GPU after crashes
125+
- **X11 Session**: Works automatically
126+
- **Snap Package**: Uses native display server
127+
128+
## Reporting Issues
129+
130+
When reporting display server issues, include:
131+
132+
1. Display server type: `echo $XDG_SESSION_TYPE`
133+
2. Graphics card: `lspci | grep -i vga`
134+
3. Distribution: `cat /etc/os-release`
135+
4. Package type: snap/deb/rpm/AppImage
136+
5. Full error output with `--enable-logging --v=1`

electron-builder.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,26 @@
133133
"deb": {
134134
"fpm": [
135135
"--after-install=build/linux/postinst.sh"
136+
],
137+
"recommends": [
138+
"xdg-desktop-portal",
139+
"xdg-desktop-portal-gtk"
136140
]
137141
},
138142
"rpm": {
139-
"fpm": ["--rpm-rpmbuild-define=_build_id_links none"]
143+
"fpm": [
144+
"--rpm-rpmbuild-define=_build_id_links none",
145+
"--rpm-tag=Recommends: xdg-desktop-portal",
146+
"--rpm-tag=Recommends: xdg-desktop-portal-gtk"
147+
]
140148
},
141149
"snap": {
142150
"plugs": [
143151
"desktop",
144152
"desktop-legacy",
145153
"home",
146154
"x11",
155+
"wayland",
147156
"unity7",
148157
"browser-support",
149158
"network",
@@ -154,9 +163,9 @@
154163
"audio-playback",
155164
"audio-record",
156165
"screen-inhibit-control",
157-
"upower-observe"
158-
],
159-
"executableArgs": ["--ozone-platform=x11"]
166+
"upower-observe",
167+
"pipewire"
168+
]
160169
},
161170
"afterSign": "./build/notarize.js",
162171
"generateUpdatesFilesForAllChannels": true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"productName": "Rocket.Chat",
77
"name": "rocketchat",
88
"description": "Official OSX, Windows, and Linux Desktop Clients for Rocket.Chat",
9-
"version": "4.10.1",
9+
"version": "4.10.2",
1010
"author": "Rocket.Chat Support <support@rocket.chat>",
1111
"copyright": "© 2016-2025, Rocket.Chat",
1212
"homepage": "https://rocket.chat",

rollup.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,14 @@ const run = () => {
3434
proc ? 'Restarting main process...' : 'Starting main process...'
3535
);
3636

37-
proc = spawn(electron, ['.'], { stdio: 'inherit' });
37+
const electronArgs = ['.'];
38+
39+
// Linux-specific flags for development
40+
if (process.platform === 'linux') {
41+
electronArgs.push('--no-sandbox');
42+
}
43+
44+
proc = spawn(electron, electronArgs, { stdio: 'inherit' });
3845

3946
proc.on('close', () => {
4047
proc = null;

scripts/README.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Testing Scripts
2+
3+
This directory contains automation scripts for testing Rocket.Chat Desktop on Linux.
4+
5+
## Scripts
6+
7+
### `install-volta.sh`
8+
9+
Installs Volta (JavaScript toolchain manager) if it's not already installed. Volta provides node.js and npm, which are required for building the project.
10+
11+
#### Usage
12+
13+
```bash
14+
# Interactive mode (prompts before installing)
15+
./scripts/install-volta.sh
16+
17+
# Non-interactive mode (installs automatically)
18+
./scripts/install-volta.sh --non-interactive
19+
```
20+
21+
#### What It Does
22+
23+
1. **Checks if Volta is installed**
24+
- Looks for `volta` command in PATH
25+
- Checks `$VOLTA_HOME` environment variable
26+
- Checks common installation location (`~/.volta/bin/volta`)
27+
28+
2. **Installs Volta if missing**
29+
- Downloads and runs the official Volta installer
30+
- Adds Volta to PATH for current session
31+
- Adds Volta to `~/.bashrc` for future sessions
32+
33+
3. **Verifies installation**
34+
- Checks that `volta` command is available
35+
- Displays Volta version
36+
37+
#### Features
38+
39+
- Can be sourced by other scripts to use its functions
40+
- Non-interactive mode for CI/automation
41+
- Automatically adds Volta to shell profile
42+
- Safe to run multiple times (skips if already installed)
43+
44+
#### Requirements
45+
46+
- `curl` (for downloading Volta installer)
47+
- Internet connection
48+
49+
### `linux-test-deb.sh`
50+
51+
Builds, installs, and runs the Rocket.Chat Desktop .deb package for testing purposes.
52+
53+
#### Usage
54+
55+
```bash
56+
./scripts/linux-test-deb.sh [OPTIONS]
57+
```
58+
59+
#### Options
60+
61+
- `--skip-build` - Skip building the .deb package (useful if you've already built it)
62+
- `--skip-install` - Skip installing the .deb package (useful for testing installation separately)
63+
- `--skip-run` - Skip running the installed app (useful if you just want to install)
64+
- `--help`, `-h` - Show help message
65+
66+
#### Examples
67+
68+
Build, install, and run:
69+
```bash
70+
./scripts/linux-test-deb.sh
71+
```
72+
73+
Skip build if .deb already exists:
74+
```bash
75+
./scripts/linux-test-deb.sh --skip-build
76+
```
77+
78+
Only build and install, don't run:
79+
```bash
80+
./scripts/linux-test-deb.sh --skip-run
81+
```
82+
83+
#### What It Does
84+
85+
1. **Builds the .deb package**
86+
- Runs `yarn build-linux` to build the app and create Linux packages
87+
- Outputs to `dist/` directory
88+
89+
2. **Finds the .deb file**
90+
- Searches for `dist/rocketchat-*-linux-*.deb`
91+
- Uses the first matching file found
92+
93+
3. **Installs the .deb package**
94+
- Uninstalls any previous version if present
95+
- Installs the new package using `dpkg -i`
96+
- Automatically fixes missing dependencies with `apt-get install -f`
97+
98+
4. **Runs the installed app**
99+
- Launches Rocket.Chat Desktop from `/opt/Rocket.Chat/rocketchat-desktop`
100+
- Runs in background and displays the process ID
101+
102+
#### Requirements
103+
104+
- Linux operating system
105+
- `node.js` and `yarn` (or Volta - the script will install it automatically if needed)
106+
- `dpkg` and `apt-get` (standard on Debian/Ubuntu systems)
107+
- `curl` (for installing Volta if needed)
108+
- Sudo access (for installation, if not running as root)
109+
110+
#### Automatic Dependency Installation
111+
112+
The script automatically installs missing dependencies:
113+
- **Volta** (if node.js/yarn not found) - provides node.js and npm
114+
- **binutils** (if `ar` command not found) - required for building .deb packages
115+
- **Package dependencies** - automatically resolved during .deb installation
116+
117+
#### Output
118+
119+
The script provides color-coded output:
120+
- 🔵 Blue: Informational messages
121+
- 🟢 Green: Success messages
122+
- 🟡 Yellow: Warnings
123+
- 🔴 Red: Errors
124+
125+
#### Error Handling
126+
127+
The script will exit with a non-zero status code if any step fails. Common issues:
128+
129+
- **Build fails**: Check that all dependencies are installed (`yarn install`)
130+
- **Install fails**: Ensure you have sudo access and the .deb file is valid
131+
- **App not found**: The installation path may differ; check `/opt/Rocket.Chat/` or use `which rocketchat-desktop`
132+
133+
#### Notes
134+
135+
- The script automatically handles uninstalling previous versions
136+
- Missing dependencies are automatically resolved during installation
137+
- The app runs in the background; use `kill <PID>` to stop it
138+
- This script is intended for development/testing purposes only
139+

0 commit comments

Comments
 (0)