Firefox Flatpak has missing mouse cursors in native Wayland mode

I’m running GNOME on Wayland on NixOS 22.11. I am also running Firefox from Flathub in native Wayland mode (MOZ_ENABLE_WAYLAND=1 set using Flatseal). I can confirm in about:support that Wayland is being used.

Firefox runs fine, but the mouse cursor is often missing, or shows the wrong cursor as I move it around within the Firefox window. If I run Firefox on the command line with flatpak run org.mozilla.firefox, then I see lots of errors being outputted. Some examples:

Gdk-Message: 22:00:51.880: Unable to load sw-resize from the cursor theme
Gdk-Message: 22:00:51.880: Unable to load s-resize from the cursor theme
Gdk-Message: 22:00:51.880: Unable to load se-resize from the cursor theme
Gdk-Message: 22:00:52.125: Unable to load left_ptr from the cursor theme
Gdk-Message: 22:00:52.150: Unable to load nw-resize from the cursor theme
Gdk-Message: 22:00:52.150: Unable to load n-resize from the cursor theme

I’ve done some Googling and tried things like installing Adwaita themes in flatpak (org.gtk.Gtk3theme.adw-gtk3), and installing the gnome.adwaita-icon-theme nix package. Neither of these solved the problem for me.

I confirm that the same Firefox flatpak does not have this problem when running on Fedora Silverblue on the same machine.

I should note that I have not customized the cursor themes or GNOME plugins. This is a fresh NixOS install, with default GNOME settings.

Seems like Firefox can’t find the relevant icons in any gtk theme. You probably need to strace Firefox and check where it is searching for gtk themes, then symlink a theme into where the flatpak Firefox is expecting them. For the nixpkgs Firefox, having gnome.adwaita-icon-theme installed in configuration.nix puts things in the right place.

1 Like

I came across a comment on Reddit that says this is also an issue on Fedora Silverblue (link). Those commentors are using Sway, not GNOME, and personally I do not have issues on Silverblue, but it sounds like this might be a problem in the Firefox flatpak.

You should be able to fix it though. Those warnings are just gtk libs saying they can’t find icons. Just need to figure out where Firefox is searching for them and put them there

As an update, I didn’t get around to using strace to figure out where Firefox was looking for cursors. In the meantime, the issue has fixed itself. :man_shrugging:

this is still an issue for me.
it is reproducible - just install firefox flatpak on nixos 23.05, then add env overrid MOZ_ENABLE_WAYLAND=1 so it works on wayland

Here’s this issue described for another distro, there the reason was that firefox needed access to some system icons

While wrong pointers are annoying, what is more annoying is that it pollutes system journal with warnings about not being able to find cursor hand2 …

The NixOS wiki has had a solution to these problems for a while now: Fonts - NixOS Wiki

i’m confused. There is no problems with fonts, the problem is with cursors, mouse pointers.
Are mouse pointers provided by fonts??

No, but for whatever reason the recommendation on how to fix icons is on that page too (adding the .icons directory). That whole section should probably be on the flatpak article, at the moment it just links from the flatpak article to this section.

Feel free to do some wiki maintenance if this bothers you.

Ultimately that page explains the problem and describes the solution though. NixOS doesn’t use standard fhs paths so flatpak lacks permissions for the icons directory.

Personally I still think we need a flatpak module for managing this stuff, but it’s tricky. Flatpak wasn’t designed with declarative config in mind, and mucking with the internals is annoying because they have barely any documentation and often end up behaving weirdly (probably need to update some database somewhere or do some dbus magic).

Thank you,
I’ve noticed a line about .icons, but thought it’s out of place, as the suggested option fonts.fontDir.enable does not create any icons dir, and article doesn’t mention linking that dir from anywhere, and that dir (~/.icons) does not exist by default
so the article is definitely missing something… maybe xdg.icons.enable option? i’ve just looked it up and not sure if it provides icons dir similar to what fonts.fontDir.enable does for fonts

Ah, yes. I suspect it isn’t mentioned because it’s enabled by default, and the original author just… Forgot? The directory is in /run/current-system/sw/share/icons I believe.

The wiki is a bit of a mess. Lots of information is half there, though!

indeed! i do have /run/current-system/sw/share/icons
i’ve linked it to ~/.icons, allowed firefox flatpak access to it… and it changed nothing at all :frowning:

I would expect you to also need to add /run/current-system/sw/share/icons and /nix/store if you symlink it, see Flatpak can't access system fonts and icons · Issue #119433 · NixOS/nixpkgs · GitHub for more context.

Also note that ~/.icons and ~/.fonts have been superseded by icons and fonts directories in $XDG_DATA_HOME (~/.local/share by default).

1 Like

I wonder why this apparently is not necessary for fonts. I was surprised that symlinks to inaccessible paths would work.

At the very least the wiki entry should be updated once this is confirmed to work, I’ll give that a go

i did add /nix for tests, but it did not affect the result

i’ve also looked at other flatpaks, such as telegram - it has some cursor theme it ships with, not system one, and i could not find those cursors in any of those specified locations, and nothing was binded anywhere outside.
So I consider this to be a bug of how firefox is packed into the flatpak, that it doesn’t come with at least some complete set of cursors.
but as for how to fix it - not sure. i will try binding ~/.local/share/icons a bit later - that’s the only one i haven’t tried yet

ok, nothing has any effect on firefox’s cursors

tried binding into flatpak

  • ~/.icons
  • ~/.local/share/icons

both with and without binding /nix as well

firefox does not care

For future readers, I had a somewhat similar problem of cursors not working properly in Firefox (along with Flatpak GTK apps looking very ugly in general with no font anti-aliasing or cursor icons), and the solution was in this issue: ugly font rendering in GTK apps when using xdg-desktop-portal · Issue #108855 · NixOS/nixpkgs · GitHub

TL;DR: I had to enable the xdg-desktop-portal-gtk portal (xdg.portal.extraPackages = [ pkgs.xdg-desktop-portal-gtk ]). I’m using KDE Wayland (whose default portal is xdg-desktop-portal-kde), on NixOS 23.05.