Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dock icon not shown when run from within AppImage #2

Closed
probonopd opened this issue Mar 25, 2017 · 22 comments
Closed

Dock icon not shown when run from within AppImage #2

probonopd opened this issue Mar 25, 2017 · 22 comments
Labels

Comments

@probonopd
Copy link
Owner

probonopd commented Mar 25, 2017

On Ubuntu 16.04:

me@host:~$ sudo strace -eopen -f ./qtquickapp-git.bacf740-x86-64.appimage 2>&1 | grep pix
[pid  3517] open("/tmp/.mount_9gxq2L/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7
[pid  3517] open("/tmp/.mount_9gxq2L/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7

screenshot from 2017-03-25 16-28-45

Strangely, when we extract the AppImage and run it then, then it works:

me@host:~$ ./qtquickapp-git.bacf740-x86-64.appimage --appimage-extract
me@host:~$ sudo strace -eopen -f squashfs-root/AppRun 2>&1 | grep pix
[pid  3710] open("/home/me/squashfs-root/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 6
[pid  3710] open("/home/me/squashfs-root/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 6

screenshot from 2017-03-25 16-29-08

I cannot currently explain this behaviour.

@probonopd probonopd added the bug label Mar 25, 2017
@crayxt
Copy link

crayxt commented Mar 25, 2017

Hi, it think it is an app icon, not tray icon? And I just tried Ubuntu 17.04 beta, and app icon appears just fine when run from appimage directly.

@probonopd probonopd changed the title Tray icon not shown when run from within AppImage Dock icon not shown when run from within AppImage Mar 25, 2017
@probonopd
Copy link
Owner Author

probonopd commented Mar 25, 2017

Technically it is the icon of the window which we are setting here.

@probonopd
Copy link
Owner Author

probonopd commented Mar 25, 2017

@crayxt out of curiosity, do you get open() ... = 6 or = 7 when you run the above commands?

@crayxt
Copy link

crayxt commented Mar 25, 2017

@probonopd It is much stranger now, when the appimage in ~ directory, app icon does not show up, but when launched from ~/Downloads, then it does appear. strace gives 7 for both cases.

@crayxt
Copy link

crayxt commented Mar 25, 2017

I mean when you launch appimage from regular DE, there is nothing in tray area, that's why I pointed out that it is not a tray icon. Nevermind ;)

@probonopd
Copy link
Owner Author

Do you have appimaged running?

@crayxt
Copy link

crayxt commented Mar 25, 2017

Nope it is a live cd

@probonopd
Copy link
Owner Author

me@host:~$ ./qtquickapp-git.bacf740-x86-64.appimage --appimage-mount
/tmp/.mount_5DG5bM
me@host:~$ /tmp/.mount_5DG5bM/AppRun

DOES show the icon on ubuntu-16.04-desktop-amd64.iso whereas

me@host:~$ ./qtquickapp-git.bacf740-x86-64.appimage

does not.

@TheAssassin
Copy link

open() returns a file descriptor, and that's nothing but a simple integer.
See e.g. http://man7.org/linux/man-pages/man2/open.2.html for more information (or consult your local man 2 open).

I assume that the fd counter is increased whenever a new file is opened. That leads to the assumption that Qt internally opens one file less when it doesn't work.

@probonopd
Copy link
Owner Author

A fuller strace:

## Not working when running directly

root@host:/home/me# strace -eopen -f ./qtquickapp-git.bacf740-x86-64.appimage  2>&1 | grep pix -C 5
[pid 12208] open("/usr/share/X11/xkb/symbols/level3", O_RDONLY) = 7
[pid 12208] open("/usr/share/X11/xkb/symbols/level3", O_RDONLY) = 7
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/xcbglintegrations", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 7
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/xcbglintegrations/libqxcb-glx-integration.so", O_RDONLY|O_CLOEXEC) = 7
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/xcbglintegrations/libqxcb-glx-integration.so", O_RDONLY|O_CLOEXEC) = 7
[pid 12208] open("/tmp/.mount_b7CyL4/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7
[pid 12208] open("/usr/share/mime/mime.cache", O_RDONLY|O_CLOEXEC) = 8
[pid 12208] open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 9
[pid 12208] open("/usr/share/mime/types", O_RDONLY|O_CLOEXEC) = 9
[pid 12208] open("/usr/share/mime/image/png.xml", O_RDONLY|O_CLOEXEC) = 7
[pid 12208] open("/tmp/.mount_b7CyL4/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/imageformats", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 9
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/imageformats/libqgif.so", O_RDONLY|O_CLOEXEC) = 9
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/imageformats/libqico.so", O_RDONLY|O_CLOEXEC) = 9
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/imageformats/libqjpeg.so", O_RDONLY|O_CLOEXEC) = 9
[pid 12208] open("/tmp/.mount_b7CyL4/usr/plugins/imageformats/libqgif.so", O_RDONLY|O_CLOEXEC) = 9

## Working when running from mounted AppImage

root@host:/home/me# strace -eopen -f /tmp/.mount_5A4ecZ/AppRun 2>&1 | grep pix -C 5
[pid 12172] open("/usr/share/X11/xkb/symbols/level3", O_RDONLY) = 6
[pid 12172] open("/usr/share/X11/xkb/symbols/level3", O_RDONLY) = 6
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/xcbglintegrations", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 6
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/xcbglintegrations/libqxcb-glx-integration.so", O_RDONLY|O_CLOEXEC) = 6
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/xcbglintegrations/libqxcb-glx-integration.so", O_RDONLY|O_CLOEXEC) = 6
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 6
[pid 12172] open("/usr/share/mime/mime.cache", O_RDONLY|O_CLOEXEC) = 7
[pid 12172] open("/etc/localtime", O_RDONLY|O_CLOEXEC) = 8
[pid 12172] open("/usr/share/mime/types", O_RDONLY|O_CLOEXEC) = 8
[pid 12172] open("/usr/share/mime/image/png.xml", O_RDONLY|O_CLOEXEC) = 6
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 6
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/imageformats", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 8
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/imageformats/libqgif.so", O_RDONLY|O_CLOEXEC) = 8
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/imageformats/libqico.so", O_RDONLY|O_CLOEXEC) = 8
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/imageformats/libqjpeg.so", O_RDONLY|O_CLOEXEC) = 8
[pid 12172] open("/tmp/.mount_5A4ecZ/usr/plugins/imageformats/libqgif.so", O_RDONLY|O_CLOEXEC) = 8

@TheAssassin
Copy link

Both logs are equal, except for the mountpoint name (which we can ignore for now) and the return values of the open() calls. An interesting fact: They're all off by one, i.e. the working one's return values are -1.

@TheAssassin
Copy link

Just tested the file produced by Travis on my Xubuntu 16.04 desktop. In both cases, I can see QtQuickApp's icon in my task bar.
We should test this with other desktop environments, too, and see if we can narrow down the bug to Ubuntu's Unity DE.

@TheAssassin
Copy link

$ sudo strace -eopen -f ./QtQuickApp-git.bacf740-x86_64.AppImage   2>&1  | grep pix
[pid 25675] open("/tmp/.mount_8mwIOm/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7
[pid 25675] open("/tmp/.mount_8mwIOm/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7
[pid 25675] open("/usr/share/pixmaps/default/cursors/left_ptr", O_RDONLY) = -1 ENOENT (No such file or directory)

To sum up: I get the same return values for the open() calls, but the icon works perfectly fine.

screenshot_2017-03-26_00-33-30

@probonopd
Copy link
Owner Author

probonopd commented Mar 26, 2017

For what it is worth, it is working correctly from inside the AppImage on KDE neon User Edition 5.9:

screenshot_20170326_183009

me@host:~/Downloads$ sudo strace -eopen -f ./qtquickapp-git.bacf740-x86-64.appimage 2>&1  | grep pix
[pid  6152] open("/tmp/.mount_IY43lg/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7
[pid  6152] open("/tmp/.mount_IY43lg/usr/share/pixmaps/qtquickapp.png", O_RDONLY|O_CLOEXEC) = 7

@probonopd
Copy link
Owner Author

So in summary, this may be related to Ubuntu Unity only. But why?

@probonopd
Copy link
Owner Author

@Phoerius reports here:

But we are also having similar issues with our Snap package which we haven't yet solved. I suppose this is a general problem with Ubuntu and self-contained app containers.

@probonopd
Copy link
Owner Author

Note to self: Try to set/unset XDG_DATA_DIRS.

@probonopd
Copy link
Owner Author

It also works on Ubuntu 14.04 GNOME Edition:

screenshot from 2017-03-27 08-58-12

@Loxodromics
Copy link

In the latest version the icon works for me in virtual machines with Debian_8.6.0 (Gnome), openSUSE Tumbleweed (KDE) and Ubuntu 16.10 (Unity). But in no case does the icon show in the file manager – even after a restart.
screen shot 2017-03-31 at 16 40 23

@probonopd
Copy link
Owner Author

probonopd commented Mar 31, 2017

@Loxodromics the icon in the filemanager is not implemented for type 2 AppImages, see AppImage/AppImageKit#346

@Loxodromics
Copy link

@probonopd okay, I see, thank you

@probonopd
Copy link
Owner Author

probonopd commented Apr 1, 2017

@phoerious nailed it in
keepassxreboot/keepassxc#194 (comment)

I finally managed to fix this issue. It appears that Qt resolves icons also in the program's working directory, but Unity doesn't. So when Qt found the icon there, it passes it on to the tray which tries to resolve the path again, but can't find it. I fixed it by enforcing absolute icon paths for tray icons.

So, absoluteFilePath in this code

QFileInfo fi(app.applicationDirPath() + "/../share/pixmaps/qtquickapp.png");
QGuiApplication::setWindowIcon(QIcon(fi.absoluteFilePath()));

makes it work on Ubuntu Unity. Thanks @phoerious

screenshot from 2017-04-01 22-17-48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants