twang2218 / qqmusic-snap

qqmusic-snap
MIT License
6 stars 0 forks source link

No response of click on systray icon. #1

Open twang2218 opened 2 years ago

twang2218 commented 2 years ago

If the snap is installed in the devmode, everything works correctly, however, if it's installed in strict/dangerouse, the systray icon is not working correctly.

Installed in devmode

sudo snap install --devmode ./qqmusic_1.1.1_amd64.snap

Verify the mode:

➜ snap info --verbose qqmusic                                                       
name:    qqmusic
summary: QQ Music for Linux
health:
  status:  unknown
  message: health has not been set
publisher: –
license:   unset
description: |
  QQ Music provides massive high-quality music for you.
commands:
  - qqmusic
notes:               
  private:           false
  confinement:       strict
  devmode:           true
  jailmode:          false
  trymode:           false
  enabled:           true
  broken:            false
  ignore-validation: false
base:         core18
refresh-date: yesterday at 20:10 AEST
installed:    1.1.1 (x1) 110MB devmode

Launch the qqmusic via cli

➜ qqmusic                                 
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Gtk-Message: 14:24:41.446: Failed to load module "canberra-gtk-module"
Gtk-Message: 14:24:41.465: Failed to load module "canberra-gtk-module"
(electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false".  It will change to be "true" in Electron 9.  For more information please check https://github.com/electron/electron/issues/18397
(node:497255) UnhandledPromiseRejectionWarning: undefined
(node:497255) UnhandledPromiseRejectionWarning: undefined
(node:497255) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:497255) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:497255) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:497255) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
login refresh fail
(node:497255) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:497255) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(electron) 'setUserAgent function' is deprecated and will be removed. Please use 'userAgent property' instead.

At the same time, the /var/log/kern.log content is following:

Sep 17 14:24:42 purrbuntu kernel: [353140.318443] audit: type=1107 audit(1631852682.480:1015366): pid=1682 uid=103 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=497255 label="snap.qqmusic.qqmusic" peer_pid=1677 peer_label="unconfined"
Sep 17 14:24:42 purrbuntu kernel: [353140.318443]  exe="/usr/bin/dbus-daemon" sauid=103 hostname=? addr=? terminal=?'
Sep 17 14:24:43 purrbuntu kernel: [353141.066130] audit: type=1326 audit(1631852683.228:1015367): auid=1000 uid=1000 gid=1000 ses=3 pid=497255 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7efc3aaa04b7 code=0x7ffc0000
Sep 17 14:24:43 purrbuntu kernel: [353141.126718] audit: type=1107 audit(1631852683.288:1015368): pid=1682 uid=103 auid=4294967295 ses=4294967295 msg='apparmor="ALLOWED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=497255 label="snap.qqmusic.qqmusic" peer_pid=1677 peer_label="unconfined"
Sep 17 14:24:43 purrbuntu kernel: [353141.126718]  exe="/usr/bin/dbus-daemon" sauid=103 hostname=? addr=? terminal=?'
Sep 17 14:24:45 purrbuntu kernel: [353143.008397] audit: type=1326 audit(1631852685.168:1015369): auid=1000 uid=1000 gid=1000 ses=3 pid=497400 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7f7dfff764b7 code=0x7ffc0000

And the systray icon works correctly.

2021-09-17 14-25-11 的屏幕截图

Installed in strict/dangerous mode

sudo snap install --dangerous ./qqmusic_1.1.1_amd64.snap

The mode can be verified by CLI:

➜ snap info --verbose qqmusic                                                         
name:    qqmusic
summary: QQ Music for Linux
health:
  status:  unknown
  message: health has not been set
publisher: –
license:   unset
description: |
  QQ Music provides massive high-quality music for you.
commands:
  - qqmusic
notes:               
  private:           false
  confinement:       strict
  devmode:           false
  jailmode:          false
  trymode:           false
  enabled:           true
  broken:            false
  ignore-validation: false
base:         core18
refresh-date: today at 14:29 AEST
installed:    1.1.1 (x1) 110MB -

Launch the qqmusic from command line:

➜ qqmusic
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Gtk-Message: 14:32:50.482: Failed to load module "canberra-gtk-module"
Gtk-Message: 14:32:50.485: Failed to load module "canberra-gtk-module"
(electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false".  It will change to be "true" in Electron 9.  For more information please check https://github.com/electron/electron/issues/18397
(node:501785) UnhandledPromiseRejectionWarning: undefined
(node:501785) UnhandledPromiseRejectionWarning: undefined
(node:501785) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:501785) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:501785) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:501785) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
login refresh fail
(node:501785) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
(node:501785) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 1)
stderr: dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.18543" (uid=1000 pid=501935 comm="dbus-monitor --session type='signal',interface='or" label="snap.qqmusic.qqmusic (enforce)") interface="org.freedesktop.DBus.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to eavesdropping.

(electron) 'setUserAgent function' is deprecated and will be removed. Please use 'userAgent property' instead.

The /var/log/kern.log output for the launch is:

Sep 17 14:32:50 purrbuntu kernel: [353628.627303] audit: type=1107 audit(1631853170.758:1015479): pid=1682 uid=103 auid=4294967295 ses=4294967295 msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=501785 label="snap.qqmusic.qqmusic" peer_pid=1677 peer_label="unconfined"
Sep 17 14:32:50 purrbuntu kernel: [353628.627303]  exe="/usr/bin/dbus-daemon" sauid=103 hostname=? addr=? terminal=?'
Sep 17 14:32:50 purrbuntu kernel: [353628.748537] audit: type=1326 audit(1631853170.882:1015480): auid=1000 uid=1000 gid=1000 ses=3 pid=501785 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7f6d221ff4b7 code=0x50000
Sep 17 14:32:51 purrbuntu kernel: [353629.560219] audit: type=1326 audit(1631853171.694:1015481): auid=1000 uid=1000 gid=1000 ses=3 pid=501921 comm="qqmusic" exe="/snap/qqmusic/x1/opt/qqmusic/qqmusic" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7f4e52b624b7 code=0x50000

And nothing happened if click on the qqmusic systray icon.

Problem

The bluez error should not be the problem, I can overcome it by connecting it to bluez interface, and the result is the same.

The following error caught my eyes, and I'm not sure whether it's the cause of the problem:

stderr: dbus-monitor: unable to enable new-style monitoring: org.freedesktop.DBus.Error.AccessDenied: "An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.18543" (uid=1000 pid=501935 comm="dbus-monitor --session type='signal',interface='or" label="snap.qqmusic.qqmusic (enforce)") interface="org.freedesktop.DBus.Monitoring" member="BecomeMonitor" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus)". Falling back to eavesdropping.

twang2218 commented 2 years ago

Raised the problem in snapcraft.io (https://forum.snapcraft.io/t/trouble-to-get-electron-apps-systray-icon-working-as-a-snap/26623)

twang2218 commented 2 years ago

Current workaround of the problem, fix the AppArmor profiles by provided script:

sudo /snap/qqmusic-snap/current/fix-tray.sh

The script fix-tray.sh will patch and reload the AppArmor profile for qqmusic-snap. Relaunch the qqmusic-snap, the systray should work correctly.

twang2218 commented 2 years ago

Update:

I send the pull request: snapcore/snapd#10873 at 2nd Oct, and it's been merged at 18 Oct, it's marked to be part of snapd 2.53. So, the fix-tray.sh workaround will not be necessary after the release of 2.53.