web stats
Featured image of post How to Fix Microsoft Edge Crashing on Linux (Wayland) When Downloading Files

How to Fix Microsoft Edge Crashing on Linux (Wayland) When Downloading Files

How to fix Microsoft Edge crashing on Linux when downloading files while in a Wayland session.

If you’re a Linux desktop user, you’re likely using Wayland as your display server. And if you’re also one of those people who use Microsoft Edge, you might have run into a frustrating issue with recent versions of the browser: it closes completely (crashes) the instant you try to download any file.

It doesn’t seem to be a one-off issue. Fortunately, the problem has a clear diagnosis and a fairly simple solution. Let’s fix this problem step-by-step:

What’s Happening?

When the browser crashes, the first thing to do is run it from a terminal to see what it tells us. If you run microsoft-edge and trigger the crash, you’ll probably see an error log similar to this one from libwayland: exported surface had an invalid role

1
2
3
4
5
❯ microsoft-edge
[...errors omitted...]
[505387:505387:1104/130749.871196:ERROR:ui/events/platform/wayland/wayland_event_watcher.cc:47] libwayland: zxdg_exporter_v2#25: error 0: exported surface had an invalid role
[...errors omitted...]
[1]    505387 trace trap (core dumped)  microsoft-edge

In plain English: When you try to download something, Edge (which is based on Chromium) tries to open the “Save As” dialog using the native Wayland protocol. However, it assigns it a “role” (a type of window) that your Wayland compositor (like Mutter in GNOME or KWin in KDE) doesn’t understand or considers invalid. This disagreement causes a fatal error, and the browser closes without any further explanation.

The Solution, Step-by-Step

The solution is to force Microsoft Edge to not use Wayland natively. Instead, it will run through XWayland, a compatibility layer for X11 applications that exists for exactly this type of situation.

Step 1: Verify the Solution

First, let’s confirm this is the solution. Completely close all Microsoft Edge windows you might have open.

Next, open a terminal and run the following command:

1
microsoft-edge --ozone-platform=x11

This command tells Edge: “Ignore Wayland and run using the X11 compatibility layer (XWayland).”

Now, with the browser open from that terminal, try to download a file. The “Save As” dialog should appear without any issues, and the browser will no longer crash.

Note: You might see some new errors in the terminal, like GetVSyncParametersIfAvailable() failed. Don’t worry! These are minor, non-fatal warnings related to the compatibility layer, and you can safely ignore them. The important thing is that the crash is gone.

Step 2: Apply the Permanent Solution

Now that we know what the problem is and how to fix it, let’s make this change permanent so Edge always starts with this setting, regardless of whether you open it from your dock icon or the applications menu.

To do this, we will modify the application’s .desktop file (its launcher).

  • Copy the launcher to your local directory:

We are not going to edit the system file directly, as sudo is unnecessary and a browser update could overwrite our changes. Instead, we’ll copy it to our user profile. Keep in mind that the filename might vary depending on whether you are using the stable, dev, etc., version.

1
cp /usr/share/applications/microsoft-edge.desktop ~/.local/share/applications/
  • Open the file for editing:

Now, open this new file with a text editor. Let’s use nano as an example:

1
nano ~/.local/share/applications/microsoft-edge.desktop
  • Modify the Exec lines:

Inside this file, you’ll see several lines that start with Exec=. These lines tell the system how to run the program. You need to find all the Exec= lines that run the main binary (like Exec=/usr/bin/microsoft-edge-stable %U or Exec=/usr/bin/microsoft-edge-stable --in-private-browsing) and add the --ozone-platform=x11 flag to them.

Make sure to add it after the command but before any variables like %U or --new-window.

Example (Before):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[Desktop Entry]
...
Exec=/usr/bin/microsoft-edge-stable %U
...
[Desktop Action new-window]
...
Exec=/usr/bin/microsoft-edge-stable --new-window
...
[Desktop Action new-private-window]
...
Exec=/usr/bin/microsoft-edge-stable --in-private-browsing

Example (After):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[Desktop Entry]
...
Exec=/usr/bin/microsoft-edge-stable --ozone-platform=x11 %U
...
[Desktop Action new-window]
...
Exec=/usr/bin/microsoft-edge-stable --ozone-platform=x11 --new-window
...
[Desktop Action new-private-window]
...
Exec=/usr/bin/microsoft-edge-stable --ozone-platform=x11 --in-private-browsing
  • Save and Exit:

Continuing with the previous example, in nano, we save by pressing Ctrl + O (Enter) and then exit with Ctrl + X.

And that’s it! Now we will automatically use the modified and fully functional launcher :)

PS: Banner image generated with A.I.

comments powered by Disqus
Built with Hugo-Extended & theme Stack