Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9689386
feat: Enhance Linux support for screen sharing and dependencies
jeanfbrito Dec 16, 2025
74d4c52
chore: Bump version to 4.10.2 in package.json
jeanfbrito Dec 16, 2025
5fd2177
feat(videoCall): Implement screen sharing request handling and cleanu…
jeanfbrito Dec 16, 2025
43fca4f
fix(videoCall): Improve screen sharing timeout handling and listener …
jeanfbrito Dec 16, 2025
bf19755
fix(videoCall): Refactor screen sharing listener cleanup and request …
jeanfbrito Dec 16, 2025
1536973
feat(gpuFallback): Implement GPU crash detection and fallback mode fo…
jeanfbrito Dec 17, 2025
14e6054
fix(app): Adjust crash count condition and preserve command-line argu…
jeanfbrito Dec 17, 2025
e215b0a
feat: Enhance Linux display server support and crash handling
jeanfbrito Dec 17, 2025
f16c74e
refactor(app): Streamline GPU crash handling and fallback logic
jeanfbrito Dec 17, 2025
ee99e2a
docs: Update Linux display server documentation and improve GPU crash…
jeanfbrito Dec 17, 2025
717c3d8
feat(scripts): Add installation and testing scripts for Linux
jeanfbrito Dec 18, 2025
afa9bcb
refactor(scripts): Improve error handling in installation and depende…
jeanfbrito Dec 19, 2025
6aeb28a
feat(linux): Enhance Wayland and X11 support for GPU handling
jeanfbrito Dec 19, 2025
2d67ca3
feat(videoCall): Introduce screen picker functionality for enhanced s…
jeanfbrito Dec 19, 2025
88f0833
refactor(videoCall): Improve screen sharing request handling and list…
jeanfbrito Dec 19, 2025
357e1d0
refactor(videoCall): Enhance webview handler setup and error management
jeanfbrito Dec 19, 2025
7c53c96
refactor(gpuFallback): Extend valid fallback modes and improve type s…
jeanfbrito Dec 19, 2025
da81f02
refactor(gpuFallback): Improve fallback mode handling in reducer
jeanfbrito Dec 19, 2025
54cb4bc
refactor(videoCall): Update display media request handling for improv…
jeanfbrito Dec 19, 2025
89b7f94
refactor(config): Clean up whitespace and improve logging consistency
jeanfbrito Dec 19, 2025
3bcca07
fix(build): Update electron-builder command to include appimage target
jeanfbrito Dec 22, 2025
1a4364e
feat(build): Add AppImage support to pull request workflow
jeanfbrito Dec 22, 2025
0c89de9
fix(build): Correct AppImage file extension in pull request workflow
jeanfbrito Dec 22, 2025
580c11d
fix(build): Add AppImage pattern to pull request workflow file matching
jeanfbrito Dec 22, 2025
6a5f124
feat(scripts): Add Linux AppImage testing script
jeanfbrito Dec 22, 2025
6afd8e1
refactor(gpuFallback): Simplify GPU fallback handling and improve log…
jeanfbrito Dec 22, 2025
55efccf
refactor(gpuFallback): Enhance Wayland handling and logging for X11 f…
jeanfbrito Dec 22, 2025
3a2cda8
feat(wayland): Enable native Wayland support by default
jeanfbrito Dec 23, 2025
7f469bb
fix: Address PR review comments
jeanfbrito Dec 23, 2025
602f141
fix(linux): Enforce X11 mode on Wayland sessions
jeanfbrito Dec 23, 2025
74faa87
feat(wayland): Enable native Wayland support by default
jeanfbrito Dec 23, 2025
b3615b7
fix(linux): Add proactive GPU detection with X11 fallback
jeanfbrito Dec 23, 2025
ca1b08f
fix(ci): Fix AppImage upload and PR comment updates
jeanfbrito Dec 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,18 @@
"deb": {
"fpm": [
"--after-install=build/linux/postinst.sh"
],
"recommends": [
"xdg-desktop-portal",
"xdg-desktop-portal-gtk"
]
},
"rpm": {
"fpm": ["--rpm-rpmbuild-define=_build_id_links none"]
"fpm": [
"--rpm-rpmbuild-define=_build_id_links none",
"--rpm-tag=Recommends: xdg-desktop-portal",
"--rpm-tag=Recommends: xdg-desktop-portal-gtk"
]
},
"snap": {
"plugs": [
Expand All @@ -154,9 +162,9 @@
"audio-playback",
"audio-record",
"screen-inhibit-control",
"upower-observe"
],
"executableArgs": ["--ozone-platform=x11"]
"upower-observe",
"pipewire"
]
},
"afterSign": "./build/notarize.js",
"generateUpdatesFilesForAllChannels": true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"productName": "Rocket.Chat",
"name": "rocketchat",
"description": "Official OSX, Windows, and Linux Desktop Clients for Rocket.Chat",
"version": "4.10.1",
"version": "4.10.2",
"author": "Rocket.Chat Support <support@rocket.chat>",
"copyright": "© 2016-2025, Rocket.Chat",
"homepage": "https://rocket.chat",
Expand Down
9 changes: 5 additions & 4 deletions src/app/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ export const performElectronStartup = (): void => {
app.commandLine.appendSwitch('disable-accelerated-video-decode');
}

if (process.platform === 'linux') {
app.commandLine.appendSwitch('ozone-platform', 'x11');
}

const args = process.argv.slice(app.isPackaged ? 1 : 2);

if (args.includes('--reset-app-data')) {
Expand Down Expand Up @@ -142,6 +138,11 @@ export const performElectronStartup = (): void => {
'disable-features',
disabledChromiumFeatures.join(',')
);

// Enable PipeWire screen capture for Linux (Wayland support)
if (process.platform === 'linux') {
app.commandLine.appendSwitch('enable-features', 'WebRTCPipeWireCapturer');
}
};

export const initializeScreenCaptureFallbackState = (): void => {
Expand Down
195 changes: 165 additions & 30 deletions src/videoCallWindow/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@ const SOURCE_VALIDATION_CACHE_TTL = 30000;
const DESTRUCTION_CHECK_INTERVAL = 50;
const DEVTOOLS_TIMEOUT = 2000;
const WEBVIEW_CHECK_INTERVAL = 100;
const SCREEN_SHARING_REQUEST_TIMEOUT = 60000; // 60 seconds timeout

let videoCallWindow: BrowserWindow | null = null;
let isVideoCallWindowDestroying = false;
let pendingVideoCallUrl: string | null = null;

// Screen sharing request tracking
let activeScreenSharingListener:
| ((event: Event, sourceId: string | null) => void)
| null = null;
let activeScreenSharingRequestId: string | null = null;
let screenSharingTimeout: NodeJS.Timeout | null = null;
let isScreenSharingRequestPending = false;

// Helper function to log URL changes
const setPendingVideoCallUrl = (url: string, reason: string) => {
const previous = pendingVideoCallUrl;
Expand Down Expand Up @@ -209,6 +218,9 @@ const cleanupVideoCallWindow = () => {
);
}

// Clean up screen sharing listener before removing window listeners
cleanupScreenSharingListener();

videoCallWindow.removeAllListeners();

// Use setImmediate to ensure this happens after current event loop
Expand Down Expand Up @@ -246,50 +258,167 @@ const cleanupVideoCallWindow = () => {
}, 10);
};

const cleanupScreenSharingListener = (): void => {
if (activeScreenSharingListener) {
ipcMain.removeListener(
'video-call-window/screen-sharing-source-responded',
activeScreenSharingListener
);
activeScreenSharingListener = null;
}

if (screenSharingTimeout) {
clearTimeout(screenSharingTimeout);
screenSharingTimeout = null;
}

activeScreenSharingRequestId = null;
isScreenSharingRequestPending = false;
};

const removeScreenSharingListenerOnly = (): void => {
if (activeScreenSharingListener) {
ipcMain.removeListener(
'video-call-window/screen-sharing-source-responded',
activeScreenSharingListener
);
activeScreenSharingListener = null;
}

if (screenSharingTimeout) {
clearTimeout(screenSharingTimeout);
screenSharingTimeout = null;
}
};

const markScreenSharingComplete = (): void => {
activeScreenSharingRequestId = null;
isScreenSharingRequestPending = false;
};

const setupWebviewHandlers = (webContents: WebContents) => {
const handleDidAttachWebview = (
_event: Event,
webviewWebContents: WebContents
): void => {
webviewWebContents.session.setDisplayMediaRequestHandler((_request, cb) => {
if (videoCallWindow && !videoCallWindow.isDestroyed()) {
videoCallWindow.webContents.send(
'video-call-window/open-screen-picker'
);
webviewWebContents.session.setDisplayMediaRequestHandler(
(_request, cb) => {
// Prevent concurrent requests
if (isScreenSharingRequestPending) {
console.warn(
'Screen sharing request already pending, ignoring concurrent request'
);
cb({ video: false } as any);
return;
}

ipcMain.once(
'video-call-window/screen-sharing-source-responded',
async (_event, sourceId) => {
if (!sourceId) {
cb({ video: false } as any);
return;
}
if (!videoCallWindow || videoCallWindow.isDestroyed()) {
console.warn(
'Screen sharing request rejected - video call window not available'
);
cb({ video: false } as any);
return;
}

try {
const sources = await desktopCapturer.getSources({
types: ['window', 'screen'],
});
// Clean up any existing listener
cleanupScreenSharingListener();

const selectedSource = sources.find((s) => s.id === sourceId);
// Generate unique request ID
const requestId = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
activeScreenSharingRequestId = requestId;
isScreenSharingRequestPending = true;

if (!selectedSource) {
console.warn(
'Selected screen sharing source no longer available:',
sourceId
);
cb({ video: false } as any);
return;
}
// Create the listener function
const listener = async (_event: Event, sourceId: string | null) => {
// Ignore responses for different requests
if (activeScreenSharingRequestId !== requestId) {
console.warn(
'Screen sharing response received for different request, ignoring'
);
return;
}

cb({ video: selectedSource });
} catch (error) {
console.error('Error validating screen sharing source:', error);
// Remove listener and clear timeout (prevent re-firing)
// BUT keep isScreenSharingRequestPending=true to block concurrent requests
removeScreenSharingListenerOnly();

if (!sourceId) {
cb({ video: false } as any);
// Now mark complete to allow new requests
markScreenSharingComplete();
return;
}

try {
const sources = await desktopCapturer.getSources({
types: ['window', 'screen'],
});

const selectedSource = sources.find((s) => s.id === sourceId);

if (!selectedSource) {
console.warn(
'Selected screen sharing source no longer available:',
sourceId
);
cb({ video: false } as any);
// Now mark complete to allow new requests
markScreenSharingComplete();
return;
}

cb({ video: selectedSource });
// Now mark complete to allow new requests
markScreenSharingComplete();
} catch (error) {
console.error('Error validating screen sharing source:', error);
cb({ video: false } as any);
// Now mark complete to allow new requests
markScreenSharingComplete();
}
};

// Store listener for cleanup
activeScreenSharingListener = listener;

// Set timeout to prevent orphaned listeners
screenSharingTimeout = setTimeout(() => {
// Validate that this timeout is for the current request
// This prevents double-invocation if the listener already handled it
if (activeScreenSharingRequestId !== requestId) {
console.warn(
'Screen sharing timeout fired for different request, ignoring'
);
return;
}

console.warn(
'Screen sharing request timed out, cleaning up listener'
);

// Remove listener only (keep pending flag to block concurrent requests)
removeScreenSharingListenerOnly();

// Invoke callback once (mirrors listener path)
cb({ video: false } as any);

// Now mark complete to allow new requests
markScreenSharingComplete();
}, SCREEN_SHARING_REQUEST_TIMEOUT);

// Register listener
ipcMain.once(
'video-call-window/screen-sharing-source-responded',
listener
);
}
});

// Send request to open picker
videoCallWindow.webContents.send(
'video-call-window/open-screen-picker'
);
},
{ useSystemPicker: true }
);
};

webContents.removeAllListeners('did-attach-webview');
Expand Down Expand Up @@ -508,6 +637,9 @@ export const startVideoCallWindowHandler = (): void => {
videoCallWindow.on('closed', () => {
console.log('Video call window closed - destroying completely');

// Clean up screen sharing listener
cleanupScreenSharingListener();

// Use setTimeout to ensure cleanup happens after any potential app lifecycle events
// This prevents crashes during first launch when timing is critical
setTimeout(() => {
Expand All @@ -533,6 +665,9 @@ export const startVideoCallWindowHandler = (): void => {
'Video call window close initiated - preventing JS execution'
);

// Clean up screen sharing listener
cleanupScreenSharingListener();

try {
if (videoCallWindow && !videoCallWindow.isDestroyed()) {
videoCallWindow.webContents.session.setPermissionRequestHandler(
Expand Down
Loading