ubuntu-flutter-community / musicpod

Music, radio, television and podcast player for Ubuntu, Windows, MacOs and maybe soon Android
GNU General Public License v3.0
433 stars 53 forks source link

DiscordRPC does not work inside the snap #946

Open Feichtmeier opened 6 days ago

Feichtmeier commented 6 days ago

Fails with

thread 'frb_workerpool' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/discord-rich-presence-0.2.4/src/ipc_unix.rs:90:43:
Client not connected
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Instance of 'PanicException'
#0      FlutterRustBridgeBase._transformRust2DartMessage (package:flutter_rust_bridge/src/basic.dart:128)
#1      FlutterRustBridgeBase.executeNormal.<anonymous closure> (package:flutter_rust_bridge/src/basic.dart:70)
<asynchronous suspension>
#2      FlutterDiscordRPC.setActivity (package:flutter_discord_rpc/src/flutter_discord_rpc_base.dart:81)
<asynchronous suspension>

I am using this dart package which is using this rust package:

https://github.com/KRTirtho/frb_plugins/blob/main/packages/flutter_discord_rpc/native/Cargo.toml#L18C1-L18C22

in the rust package that is being there used this is the line where it wants to create a unix socket:

https://github.com/vionya/discord-rich-presence/blob/18ecbe78c7030a31932efb550e738fef94aa7a6b/src/ipc_unix.rs#L90

@kenvandine do you know if this doable with the snap with any plug/slot? I disable this for now for linux and added a toggle setting for all inside settings

soumyaDghosh commented 3 days ago

I know, how to fix it but it needs changes in the upstream source code. Basically, the code is searching in a path is non-existent to snap context.

In snap, the XDG_RUNTIME_DIR is /run/user/1000/snap.musicpod/

Now, discord-ipc is in /run/user/1000/snap.discord/. The snap.discord folder is accounted, but you cannot access this path normally from musicpod. So, for that the path of the ipc has to be like this

$XDG_RUNTIME_DIR/../snap.discord/ipc or wherever the discord ipc is.

The problem is, I am a very big noob in rust... So, not sure if I'll be able to fix it.

Feichtmeier commented 3 days ago

I know, how to fix it but it needs changes in the upstream source code. Basically, the code is searching in a path is non-existent to snap context.

In snap, the XDG_RUNTIME_DIR is /run/user/1000/snap.musicpod/

Now, discord-ipc is in /run/user/1000/snap.discord/. The snap.discord folder is accounted, but you cannot access this path normally from musicpod. So, for that the path of the ipc has to be like this

$XDG_RUNTIME_DIR/../snap.discord/ipc or wherever the discord ipc is.

The problem is, I am a very big noob in rust... So, not sure if I'll be able to fix it.

Wow thanks for this analysis! And thank for the pull request 🤞🏻 https://github.com/vionya/discord-rich-presence/pull/42