desktop icon indicating copy to clipboard operation
desktop copied to clipboard

[Bug]: File upload with drag & drop not working (randomly) on GNOME with Wayland

Open leoniscsem opened this issue 1 year ago • 3 comments

Checks before filing an issue

  • [X] This issue doesn't reproduce on web browsers (such as in Chrome). If it does, issue reports go to the Mattermost Server repository.
  • [X] I have checked the issue tracker and have not found an issue that matches the one I'm filing.
  • [X] This issue is not a troubleshooting question. Troubleshooting questions go here: https://forum.mattermost.com/c/trouble-shoot/16.
  • [X] This issue is not a feature request. You can request features and make product suggestions here: https://mattermost.com/suggestions/.
  • [X] This issue reproduces on the most recent stable version, or the most recent prerelease version of the Mattermost Desktop App.
  • [X] I have read the contribution guidelines.

Mattermost Desktop Version

~5.10.2 commit de876ca (snap installation)~ 5.12.1 commit aa47784

Operating System

Ubuntu 22.04 LTS x64, GNOME 42.9 with Wayland & ZorinOS 17.3 (Ubuntu 22.04 LTS), GNOME 43.9 with Wayland 43.8-0+deb12u1+zorin3 (both with DEB installation from stable PPA)

Mattermost Server Version

~10.3.1 (DEB installation)~ 11.0.4 (DEB installation)

Steps to reproduce

  1. have a GNOME session with Wayland window manager
  2. go to any channel
  3. drag and drop a file from file manager

Expected behavior

After dragging a file to the main window of Mattermost, the background should go black and show the "drop file here to upload" dialogue. After releasing the file, it should be uploaded.

Observed behavior

The behaviour is not consistent. Sometimes it works on the first try. The second try then usually does not work, no dark background / upload message. Sometimes wiggling the file while hovering over the main channel triggers the dark upload background, sometimes not. Sometimes it results to an error message "file cannot be uploaded". Not dropping the file when no upload dialogue appears and re-grabbing it, then trying to drop it again sometimes yields results.

Log Output

no relevant output from main.log, only this (log level debug)

[2024-12-23 16:58:24.307] [debug] [MainWindow] saving window state {
  x: 1920,
  y: 0,
  width: 1920,
  height: 1080,
  maximized: true,
  fullscreen: false
}
[2024-12-23 16:58:36.897] [debug] [ViewManager] handleSetCurrentViewBounds { x: 1920, y: 0, width: 1920, height: 1080 }
[2024-12-23 16:58:36.899] [debug] [ModalManager] handleResizeModal {
  bounds: { x: 1920, y: 0, width: 1920, height: 1080 },
  modalQueueLength: 0
}
[2024-12-23 16:58:36.902] [debug] [ViewManager] focusCurrentView
[2024-12-23 16:58:40.262] [debug] [ViewManager] handleSetCurrentViewBounds { x: 1920, y: 0, width: 1920, height: 1080 }
[2024-12-23 16:58:40.264] [debug] [ModalManager] handleResizeModal {
  bounds: { x: 1920, y: 0, width: 1920, height: 1080 },
  modalQueueLength: 0
}
[2024-12-23 16:58:40.265] [debug] [MainWindow] saving window state {
  x: 1920,
  y: 0,
  width: 1920,
  height: 1080,
  maximized: true,
  fullscreen: false
}

Additional Information

The upload dialogue seems to be triggered randomly. I have tested the file upload functionality on Firefox 133.0.3 (deb) and Chomium 131.0.6778.139 (snap). My assumption is the issue is related to either the xwayland package (2:22.1.1-1ubuntu0.14), or Google's Wayland interpreter for Electron apps.

I do not face this issue when loading an X-server session for GNOME.

Edit: updated desktop application and server version

leoniscsem avatar Dec 23 '24 09:12 leoniscsem

I'm not sure if I'm seeing exactly what you're seeing, but I am seeing a bit of inconsistency in the responsiveness of the upload screen in the app. I went ahead and set ELECTRON_OZONE_PLATFORM_HINT=wayland in my .desktop file and it seemed to be a bit better. Perhaps give that a try?

My .desktop file for reference:

[Desktop Entry]
X-SnapInstanceName=mattermost-desktop
Name=Mattermost
X-SnapAppName=mattermost-desktop
Exec=env ELECTRON_OZONE_PLATFORM_HINT=wayland BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/mattermost-desktop_mattermost-desktop.desktop /snap/bin/mattermost-desktop %U
Terminal=false
Type=Application
Icon=/snap/mattermost-desktop/769/meta/gui/icon.png
StartupWMClass=Mattermost
Comment=Mattermost
MimeType=x-scheme-handler/mattermost;
Categories=Network;InstantMessaging;

devinbinnie avatar Jan 02 '25 16:01 devinbinnie

Meanwhile I switched to the deb installation of Mattermost (5.12.1), since there were more and more issues with the snap version. I added your env variable to my .desktop file and could fix other Wayland-Electron issues, but the drag & drop upload still does not work. At least the visual upload dialogue gets initiated, but I receive another error. "This attachment cannot be uploaded".

leoniscsem avatar Nov 13 '25 04:11 leoniscsem

I have tried to pass on different combinations of env variables:

Exec=env ELECTRON_OZONE_PLATFORM_HINT=wayland /opt/Mattermost/mattermost-desktop %U
Exec=env GDK_BACKEND=x11 /opt/Mattermost/mattermost-desktop %U
Exec=env ELECTRON_OZONE_PLATFORM_HINT=wayland GDK_BACKEND=x11 /opt/Mattermost/mattermost-desktop %U
# I am well aware the last one doesn't make sense, yet desperate men are known to clutch at every straw

Interestingly, after the upgrade I even need the ELECTRON_OZONE.. variable, otherwise I do not have a mouse pointer in full-screen mode.

When I try to disable GPU acceleration, the application stays in minimised state when passing on the variable (unusable), and without passing on the variable, no mouse pointer and no file upload visual dialogue.

Passing on the variable GDK_BACKEND=X11 has no effect at all.

It is also possible to start with appended flags: mattermost-desktop --enable-features=UseOzonePlatform,WaylandWindowDecorations --ozone-platform=wayland %U

This has the same effect as passing on the env variables, however the "This attachment cannot be uploaded." error persists.

I read that this is a general problem with Electron <39.0.x, Mattermost uses Electron 35.2.0.

leoniscsem avatar Nov 13 '25 08:11 leoniscsem