Skip to content

Commit f4fc4ec

Browse files
committed
fix: pre-emptively disable hw accel where required
1 parent 7a71e39 commit f4fc4ec

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

snap/local/opt/Mattermost/fix-default-download-dir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ fi
3636
if [[ -f "$CONFIG_PATH" ]]; then
3737
# Check for a likely broken path and replace if needed
3838
if grep "downloadLocation" "$CONFIG_PATH" | grep -q "snap/mattermost-desktop"; then
39-
sed -i -E "s|downloadLocation.*$|downloadLocation\": \"$DOWNLOAD_DIR\",|g" "$CONFIG_PATH"
39+
jq --arg p "$DOWNLOAD_DIR" '.downloadLocation = $p' "$CONFIG_PATH" > "$CONFIG_PATH.tmp"
40+
mv "$CONFIG_PATH.tmp" "$CONFIG_PATH"
4041
fi
4142
else
4243
# No config file exists, so write a sensible default downloadLocation into a new config
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Since v6.0.0, Mattermost Desktop fails to launch on machines
4+
# that do not support hardware acceleration.
5+
#
6+
# The issue was reported upstream:
7+
# https://github.com/mattermost/desktop/issues/3559
8+
#
9+
# The Mattermost configuration file can be adjusted to disable
10+
# hardware acceleration, which enables the app to start.
11+
#
12+
# This script attempts to detect cases where there is unlikely
13+
# to be adequate hardware acceleration, and either updates an
14+
# existing configuration file or creates a new one with the
15+
# appropriate setting.
16+
17+
CONFIG_PATH="${SNAP_USER_DATA}/.config/Mattermost/config.json"
18+
19+
# If the rendering device string is 'llvmpipe' then it's likely that the
20+
# app will crash with hardware acceleration enabled.
21+
if glxinfo | grep -q llvmpipe; then
22+
# Disable hardware acceleration in the configuration file.
23+
if [[ -f "$CONFIG_PATH" ]]; then
24+
jq '.enableHardwareAcceleration = false' "$CONFIG_PATH" > "$CONFIG_PATH.tmp"
25+
mv "$CONFIG_PATH.tmp" "$CONFIG_PATH"
26+
fi
27+
fi
28+
29+
exec "$@"

snap/snapcraft.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ parts:
4242
override-build: |
4343
craftctl default
4444
sed -i 's|Icon=mattermost-desktop|Icon=/usr/share/icons/hicolor/256x256/apps/mattermost-desktop.png|' ${CRAFT_PART_INSTALL}/usr/share/applications/mattermost-desktop.desktop
45+
stage-packages:
46+
# Needed for the fix-hardware-accel-with-no-renderer script
47+
- mesa-utils
48+
- jq
4549
prime:
4650
- -opt/Mattermost/chrome-sandbox
4751

@@ -53,7 +57,9 @@ parts:
5357
apps:
5458
mattermost-desktop:
5559
extensions: [gnome]
56-
command-chain: [opt/Mattermost/fix-default-download-dir]
60+
command-chain:
61+
- opt/Mattermost/fix-default-download-dir
62+
- opt/Mattermost/fix-hardware-accel-with-no-renderer
5763
command: launcher.sh
5864
desktop: usr/share/applications/mattermost-desktop.desktop
5965
autostart: mattermost-desktop.desktop

0 commit comments

Comments
 (0)