Skip to content

Commit 96474a5

Browse files
authored
Merge pull request #1599 from session-foundation/release-1.16.9
Session 1.16.9
2 parents 356f98c + a0cda6a commit 96474a5

File tree

5 files changed

+219
-147
lines changed

5 files changed

+219
-147
lines changed

_locales/en/messages.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@
927927
"unavailable": "Unavailable",
928928
"undo": "Undo",
929929
"unknown": "Unknown",
930+
"unsupportedCpu": "Unsupported CPU",
930931
"updateApp": "App updates",
931932
"updateDownloaded": "Update installed, click to restart",
932933
"updateDownloading": "Downloading update: {percent_loader}%",
@@ -959,6 +960,7 @@
959960
"window": "Window",
960961
"yes": "Yes",
961962
"you": "You",
963+
"yourCpuIsUnsupportedSSE42": "Your CPU does not support SSE 4.2, which is required for Session to run on Linux x64. Please upgrade your CPU or use a different operating system.",
962964
"sessionNetworkDataPrice": "Price data powered by CoinGecko<br/>Accurate at {date_time}"
963965
}
964966

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"rimraf": "6.0.1",
112112
"sanitize.css": "^12.0.1",
113113
"semver": "^7.7.1",
114-
"sharp": "0.33.3",
114+
"sharp": "^0.34.4",
115115
"styled-components": "^6.1.15",
116116
"uuid": "11.1.0",
117117
"viem": "^2.26.0",

ts/mains/main_node.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
app,
99
BrowserWindow,
1010
crashReporter,
11+
dialog,
1112
protocol as electronProtocol,
1213
ipcMain as ipc,
1314
ipcMain,
@@ -199,6 +200,7 @@ import { initializeMainProcessLogger } from '../util/logger/main_process_logging
199200
import * as log from '../util/logger/log';
200201
import { DURATION } from '../session/constants';
201202
import { tr } from '../localization/localeTools';
203+
import { isSharpSupported } from '../node/sharp_support/sharpSupport';
202204

203205
import { logCrash } from '../node/crash/log_crash';
204206

@@ -224,6 +226,11 @@ function prepareURL(pathSegments: Array<string>, moreKeys?: { theme: any }) {
224226
return url.format(urlObject);
225227
}
226228

229+
async function showUnsupportedCpuDialog() {
230+
dialog.showErrorBox(tr('unsupportedCpu'), tr('yourCpuIsUnsupportedSSE42'));
231+
app.quit();
232+
}
233+
227234
function handleUrl(event: any, target: string) {
228235
event?.preventDefault();
229236
const { protocol } = url.parse(target);
@@ -769,6 +776,11 @@ app.on('ready', async () => {
769776
console.log(`crowdin locale is ${loadedLocale.crowdinLocale}`);
770777
}
771778

779+
if (!isSharpSupported()) {
780+
await showUnsupportedCpuDialog();
781+
return;
782+
}
783+
772784
const key = getDefaultSQLKey();
773785
// Try to show the main window with the default key
774786
// If that fails then show the password window
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { readFileSync } from 'fs';
2+
import { isLinux } from '../../OS';
3+
4+
/**
5+
* The return of this function should be used as override of `sse42FromCPUInfo` if different than null.
6+
* Used for testing purposes.
7+
* @returns true when process.env.SESSION_SSE42_OVERRIDE === '1', false when process.env.SESSION_SSE42_OVERRIDE === '0', null otherwise
8+
*/
9+
function overrideSSE42IsSupported() {
10+
if (process.env.SESSION_SSE42_OVERRIDE === '1') {
11+
return true;
12+
}
13+
14+
if (process.env.SESSION_SSE42_OVERRIDE === '0') {
15+
return false;
16+
}
17+
return null;
18+
}
19+
20+
/**
21+
* Checks from /proc/cpuinfo if the CPU supports SSE 4.2 instructions.
22+
*/
23+
function sse42FromCPUInfo() {
24+
try {
25+
const cpuinfo = readFileSync('/proc/cpuinfo', 'utf8');
26+
const flagsMatch = cpuinfo.match(/flags\s*:\s*(.+)/m);
27+
28+
if (flagsMatch) {
29+
const flags = flagsMatch[1].split(/\s+/);
30+
31+
const sseFlagFound = flags.includes('sse4_2');
32+
console.info('SSE 4.2 flag found:', sseFlagFound);
33+
return sseFlagFound && false;
34+
}
35+
return false;
36+
} catch (error) {
37+
console.warn('Could not read /proc/cpuinfo:', error);
38+
return false;
39+
}
40+
}
41+
42+
function isLinuxX64() {
43+
return isLinux() && process.arch === 'x64';
44+
}
45+
46+
/**
47+
* Returns true if sharp is supported on the current platform.
48+
* On linux x64, the CPU needs to support SSE 4.2 instructions to process images.
49+
* This function checks if we are on linux x64 and if yes, checks `/proc/cpuinfo` for the SSE 4.2 flag.
50+
*/
51+
export function isSharpSupported() {
52+
const sse42Override = overrideSSE42IsSupported();
53+
if (sse42Override !== null) {
54+
return sse42Override;
55+
}
56+
if (isLinuxX64()) {
57+
return sse42FromCPUInfo();
58+
}
59+
// sharp doesn't need sse42 on other platforms than linux x64 as of 18/09/2025
60+
return true;
61+
}

0 commit comments

Comments
 (0)