piquan / syrinscape-url-handler

Send syrinscape:/// URLs to the player
BSD 3-Clause "New" or "Revised" License
1 stars 1 forks source link

Does this still work with v1.5.0p1 ? #1

Open develroo opened 2 months ago

develroo commented 2 months ago

Only came across this app today via the forums and thought I'd give it a spin. Compiled fine, installed fine but does not work either via the gio handler or when the executable is called directly. It doesn't throw any errors, it just doesn't do anything either.

Here is it run manually

usr/local/libexec/syrinscape-uri-handler/syrinscape-uri-handler syrinscape-sci-fi:moods/YWJzYWxvbS1zdGF0aW9uLXJpcHBlZC1yZWFkeTo6RG9ja2luZyBiYXk/play/

INFO:root:Sending Syrinscape command: syrinscape-sci-fi:moods/YWJzYWxvbS1zdGF0aW9uLXJpcHBlZC1yZWFkeTo6RG9ja2luZyBiYXk/play/
DEBUG:root:Sending command string: moods/YWJzYWxvbS1zdGF0aW9uLXJpcHBlZC1yZWFkeTo6RG9ja2luZyBiYXk/play/
DEBUG:root:Syrinscape prefs path: /home/user/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/prefs
DEBUG:root:Syrinscape command path: b'/home/user/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/URI'
DEBUG:root:Writing temporary file b'/home/user/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/tmpd_eq7i1t'
DEBUG:root:Moving to command file b'/home/user/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/URI/tmpd_eq7i1t'
DEBUG:root:URL complete: moods/YWJzYWxvbS1zdGF0aW9uLXJpcHBlZC1yZWFkeTo6RG9ja2luZyBiYXk/play/

Not sure how to debug this but for reference. I am on

If I can help in debugging please ask.

EDIT:

Just for reference. Not working on the Fantasy Player either. Even on the Demo Dungeon.

piquan commented 2 months ago

I tested it with Syrinscape SciFi Player 1.5.0-p1 on Debian 13/trixie, and it works fine. Let's make sure of a few things.

I think you know this already, but this is only for the Syrinscape Sci-Fi Player and the Syrinscape Fantasy Player. These are the versions that run and play music locally, on your own machine, without using a browser at all. It isn't for Syrinscape Online Player, either the web version or the local app.

You need to have the Syrinscape Sci-Fi Player running when you run the command. This program won't launch it by itself. It's probably possible to add some sort of auto-launch function, but I haven't tried.

The particular mood you specified is part of the Absalom Station soundset, which is paid content. You can get that mood either from the SuperSyrin subscription, or buying it individually. You can confirm that you have access by going to https://syrinscape.com/store/303-absalom-station/ ; if you have it, then that page should say "You already have access to this SoundSet." Of course, you can also choose a different mood, one that you do have access to.

You'll need to be logged in to the player for that particular mood to work. If you don't see "Absalom Station" lit up in the tabs on the left-hand side of your player, then it's not available.

If none of these help, then maybe you can narrow down the problem somewhat. You can try playing something using the player's normal interface, and then test the URL syrinscape-sci-fi:///stop-all/. That's handy, since it doesn't require you to be logged in or have purchased any content.

Failing that, try looking at the log at ~/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Player.log. You might see something like OnFileCreated: got contents: /moods/YWJzYWxvbS1zdGF0aW9uLXJpcHBlZC1yZWFkeTo6RG9ja2luZyBiYXk/play/ followed by the relevant log contents.

Let me know if this helps you narrow down the problem!

develroo commented 2 months ago

think you know this already, but this is only for the Syrinscape Sci-Fi Player and the Syrinscape Fantasy Player. These are the versions that run and play music locally, on your own machine, without using a browser at all. It isn't for Syrinscape Online Player, either the web version or the local app.

Understood. I upgraded yesterday in fact (was on 1.4.2) and so that was when I first noticed '3rd party integration' When I watched the video looked very cool, but windows only. I know it is very easy to repeat the action of 'open url with x application' in Linux as it has been a staple for years.

You need to have the Syrinscape Sci-Fi Player running when you run the command. This program won't launch it by itself. It's probably possible to add some sort of auto-launch function, but I haven't tried.

Yes.. player was live. That is where I copying the URI from. The xdg-open fails like this:

xdg-open syrinscape-sci-fi:moods/YWJzYWxvbS1zdGF0aW9uLXJpcHBlZC1yZWFkeTo6RG9ja2luZyBiYXk/play/
gio: syrinscape-sci-fi:moods/YWJzYWxvbS1zdGF0aW9uLXJpcHBlZC1yZWFkeTo6RG9ja2luZyBiYXk/play/: The specified location is not supported

Which is why I tried manually.

as far as I know the required files are all in the correct place

 ls -la /usr/local/libexec/syrinscape-uri-handler/syrinscape-uri-handler 
-rwxr-xr-x 1 root root 5131 May  5 23:19 /usr/local/libexec/syrinscape-uri-handler/syrinscape-uri-handler
ls -la /usr/local/man/man1/syrinscape-uri-handler.1 
-rw-r--r-- 1 root root 1989 May  5 23:19 /usr/local/man/man1/syrinscape-uri-handler.1
r/local/man/man1/syrinscape-uri-handler.1
ls -la /usr/local/share/applications/syrinscape-uri-handler.desktop 
-rw-r--r-- 1 root root 276 May  5 23:19 /usr/local/share/applications/syrinscape-uri-handler.desktop

And the .desktop does seem to point to the right path.

cat /usr/local/share/applications/syrinscape-uri-handler.desktop 
[Desktop Entry]
Version=1.5
Type=Application
Name=Syrinscape URI Handler
Exec=/usr/local/libexec/syrinscape-uri-handler/syrinscape-uri-handler %U
Terminal=false
NoDisplay=true
StartupNotify=false
MimeType=x-scheme-handler/syrinscape-sci-fi;x-scheme-handler/syrinscape-fantasy

Which is why I ran it by hand.

So I did as you suggested and because the log is very noisy with ensemble sounds, I restricted it to just one sound and see if I could stop it. Short answer, no. Same output as above.

usr/local/libexec/syrinscape-uri-handler/syrinscape-uri-handler syrinscape-sci-fi:///stop-all/
INFO:root:Sending Syrinscape command: syrinscape-sci-fi:///stop-all/
DEBUG:root:Sending command string: stop-all/
DEBUG:root:Syrinscape prefs path: /home/user/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/prefs
DEBUG:root:Syrinscape command path: b'/home/user/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/URI'
DEBUG:root:Writing temporary file b'/home/use/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/tmpxvejldg5'
DEBUG:root:Moving to command file b'/home/user/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/URI/tmpxvejldg5'
DEBUG:root:URL complete: stop-all/

And the output from the player log was not helpful as far as I can see. Though I did notice, the last 4 entries appears after I had already stopped from the app and was not doing anything else. Could this be a locking issue?

Play Element: Rythmic Machine (Absalom Station)
makeGameObject: distance=6.162026, angle=-180, position=(0.00, 0.00, -6.16), speed=0
SoundSample: Industrial Machine with strong rhythm 02: streaming=True: preloading...
preload: loading from URL: file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin
WWWCallback::InitAndAddComponent: request url=file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin
WWWCallback::Start: sending request url=file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin attempt=1
WWWCallback::Start: successful request url=file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin attempt=1 cancelled=False
preload: took 41ms to load from URL: file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin
SampleMemoryManager::sample_started: Industrial Machine with strong rhythm 02
Nothing to do. Sleep until there is.
makeGameObject: distance=9.115346, angle=-180, position=(0.00, 0.00, -9.12), speed=0
SoundSample: Industrial Machine with strong rhythm 02: streaming=True: preloading...
preload: loading from URL: file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin
WWWCallback::InitAndAddComponent: request url=file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin
WWWCallback::Start: sending request url=file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin attempt=1
WWWCallback::Start: successful request url=file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin attempt=1 cancelled=False
SoundSample: Industrial Machine with strong rhythm 02: streaming=True: disposing of existing www instance...
preload: took 40ms to load from URL: file:///home/rooster/.config/unity3d/Syrinscape/Syrinscape Sci-Fi Player/Chapters/8c7b8387f01c4bb362a00a21744badd1/a/888609c0-0a25-44ee-9140-9bb265603cd2.syrin
SampleMemoryManager::sample_started: Industrial Machine with strong rhythm 02
Stop Element: Rythmic Machine (Absalom Station)
ChapterManager::CommenceRefresh: loading chapter data from https://syrinscape.com/account/chapters/sci-fi/1.2.1/?uuid=5a363a4605b846b6996c3059409cdf6a&key=6dea8620e5ebbfc26d6b44bae8f237f877061253&platform=unknown&version=0.1342907
WWWCallback::InitAndAddComponent: request url=https://syrinscape.com/account/chapters/sci-fi/1.2.1/?uuid=5a363a4605b846b6996c3059409cdf6a&key=6dea8620e5ebbfc26d6b44bae8f237f877061253&platform=unknown&version=0.1342907
WWWCallback::Start: sending request url=https://syrinscape.com/account/chapters/sci-fi/1.2.1/?uuid=5a363a4605b846b6996c3059409cdf6a&key=6dea8620e5ebbfc26d6b44bae8f237f877061253&platform=unknown&version=0.1342907 attempt=1
WWWCallback::Start: successful request url=https://syrinscape.com/account/chapters/sci-fi/1.2.1/?uuid=5a363a4605b846b6996c3059409cdf6a&key=6dea8620e5ebbfc26d6b44bae8f237f877061253&platform=unknown&version=0.1342907 attempt=1 cancelled=False

Anyway, thanks for your help, and I really love the idea of this project as I can think of many cool ways I can use it, myself.

FWIW I have attached the strace output of the above command, if that helps.

syrin-uri-debug.txt

TIA

develroo commented 2 months ago

So looking through the strace myself I wanted to see if the tmp files were being created. Seems they are.

 iwatch .
[ 6/May/2024 11:21:02] IN_CREATE ./tmp529z36lb
[ 6/May/2024 11:21:02] IN_CLOSE_WRITE ./tmp529z36lb
[ 6/May/2024 11:21:02] IN_MOVED_FROM ./tmp529z36lb
[ 6/May/2024 11:21:12] IN_CLOSE_WRITE ./prefs
[ 6/May/2024 11:21:12] * ./prefs is closed

Following on from that thought is that file being put in the URI folder? Yes.

 iwatch URI/
[ 6/May/2024 11:25:51] IN_MOVED_TO URI//tmp_ffvz7v1
[ 6/May/2024 11:25:51] *  is moved to URI//tmp_ffvz7v1

Edit: Why does the file name change from tmpxxxx to tmp_xxx? Is that some sort of pre-defined spec?

develroo commented 2 months ago

So, been trying to investigate what is going on and I believe you basically paste the action into the `URI' folder, and it is supposed to detect that and act upon it. Those files are being created, but nothing as far as I can tell is reading them? I'll investigate a little further and see what it is listening to.

develroo commented 2 months ago

Ok the plot sickens. So ran strace on the Syrinscape program and scanned for where is ACTUALLY looked at the URI folder.

this is where is gets weird because I had an iwatch on the whole Syrinscape Fantasy folder and so tried to match up one to the other.

So on the strace side this is the interesting part.

521463 openat(AT_FDCWD, "/home/user/.config/unity3d/Syrinscape/Syrinscape Fantasy Player/URI", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 33
521463 openat(AT_FDCWD, "/home/user/.config/unity3d/Syrinscape/Syrinscape Fantasy Player/URI/tmp_q9whmau", O_RDONLY) = 33

And indeed in iwatch I see this.

[ 6/May/2024 12:42:15] * ./prefs is closed
[ 6/May/2024 12:42:24] IN_CREATE ./tmp_q9whmau
[ 6/May/2024 12:42:24] IN_CLOSE_WRITE ./tmp_q9whmau
[ 6/May/2024 12:42:24] IN_MOVED_FROM ./tmp_q9whmau

What is weird is there is no URI/ prefix. even though the strace said it was. Peculiar.

piquan commented 2 months ago

What you're seeing in iwatch is when the Python script is creating the file. It initially writes the file outside the URI directory, then moves it into place. This is to prevent a race condition between when it creates and populates the file, and when it's read by Syrinscape. If you include the URI directory in your iwatch command line, then you should see the move destination.

I worked on this some, and came across some findings that I can't quite interpret yet. When I wrote my program, and previously tested it, Syrinscape used polling to find new files in the URI directory. The library it uses can use a variety of change notification mechanisms to find changes.

Now it uses inotify (the same mechanism as iwatch). The flags it gives to inotify don't include anything to mark a file that was moved into that directory, so it doesn't get notified.

Curiously, though, even when I changed my code to create the file directly in the URI directory, Syrinscape wasn't consistently getting notified. I think the thread that monitors inotify events wasn't running all the time. I'm still working on that; I'm afraid I don't have time at the moment to write up my experiments, though.

You might be able to set the sysctl fs.inotify.max_user_watches=0, forcing Syrinscape to fall back to polling. But I haven't tested that. It also would interfere with iwatch, of course, if you use that, and other inotify-based mechanisms like file indexers.

I'll let you know once I learn more.

piquan commented 2 months ago

Edit: Why does the file name change from tmpxxxx to tmp_xxx? Is that some sort of pre-defined spec?

The file is created with a random filename each time, using mkstemp. The underscore is one of the random characters it might use in the filename.

It shouldn't rename the file when it changes directories, I think; maybe you saw two different files in the two traces?

develroo commented 2 months ago

Curiously, though, even when I changed my code to create the file directly in the URI directory, Syrinscape wasn't consistently getting notified. I think the thread that monitors inotify events wasn't running all the time. I'm still working on that; I'm afraid I don't have time at the moment to write up my experiments, though.

Yeah, once I found out what your program was doing (writing the command to a file and putting it in the URI folder) I started testing it myself but echoing a command to a file and seeing if there was any response from the player. I could not see it looking at that file at all, it is like it just ignore that directory but occasionally will look at it, according to the strace?

It shouldn't rename the file when it changes directories, I think; maybe you saw two different files in the two traces?

Well that is what threw me, because they are obviously random names and so did it really generate the same one twice? I might see if I can leverage ebpf to really drill down into things, but that will be non-trivial.

All a bit confusing I have to say and I am trying to figure out, is it wayland? Is it my kernel version (6.7.12-1)? Is it my Gnome version?

Honestly, not sure where to go from here. I even tried it under a guest user on KDE in case that was the issue. I am thinking this is less to do with your program and more something to do with the player, and so I should be reporting this as a bug to Syrinscape. But you said it still works for you, so I am flummoxed where I should direct my efforts.

Anyway, thanks for your efforts too. This is low priority for me atm too, but still I will help any way I can if needed.

develroo commented 2 months ago

Ok now this is interesting. While faffing around creating files and seeing if it read them I decided to clean the Player.log file and see where it actually watches for URI. So I restarted the player and lo and behold I go assailed with cacophony of noise when the player started up. It read and played all the files (I am assuming in alphabetical order) and then promptly deleted them afterwards. But subsequent writes to that folder it ignores.

Here is the except from the Player.log

URIFileWatcher: watching /home/user/.config/unity3d/Syrinscape/Syrinscape Fantasy Player/URI
Playing Force missile
Play Element: Force missile (Bugbear Battle)
makeGameObject: distance=0, angle=180, position=(0.00, 0.00, 0.00), speed=0
SoundSample: MagicMissle_ST_REV03: streaming=True: preloading...
preload: loading from URL: file:///home/user/.config/unity3d/Syrinscape/Syrinscape Fantasy Player/Chapters/f5c03a9060e2b547d9a11b86ced8c847/a/1503d440-3099-4a6a-863c-2c3f7e0a9f86.syrin
Playing Sad trombone
Play Element: Sad trombone (Bugbear Battle)
makeGameObject: distance=1, angle=0, position=(0.00, 0.00, 1.00), speed=0
preload: loading from URL: file:///home/user/.config/unity3d/Syrinscape/Syrinscape Fantasy Player/Chapters/f5c03a9060e2b547d9a11b86ced8c847/a/2d167e3a-30f3-45c1-8328-3b52acc06fe9.syrin
Playing Battle begins
Start Mood: Battle begins (Bugbear Battle)
Play Element: Curses (Bugbear Battle)
Play Element: More curses (Bugbear Battle)
Play Element: Growls (Bugbear Battle)
Play Element: Hoots and hisses (Bugbear Battle)
Play Element: Axe and shield (Bugbear Battle)
Play Element: Battle cry (Bugbear Battle)
Play Element: Battle cries (Bugbear Battle)
makeGameObject: distance=1.8, angle=29.82555, position=(0.90, 0.00, 1.56), speed=0
preload: loading from URL: file:///home/user/.config/unity3d/Syrinscape/Syrinscape Fantasy Player/Chapters/f5c03a9060e2b547d9a11b86ced8c847/a/faedbb8f-a7e6-11e2-9975-68a86d087c62.syrin
Play Element: Ill wind (Bugbear Battle)
Stop Element: Sad trombone (Bugbear Battle)
Play Element: Dramatic note (Bugbear Battle)
preload: loading from URL: file:///home/user/.config/unity3d/Syrinscape/Syrinscape Fantasy Player/Chapters/f5c03a9060e2b547d9a11b86ced8c847/a/2b51360c-4ad3-11e5-90f8-f23c9170c08b.syrin
Stop Element: Force missile (Bugbear Battle)
Play Element: Battle music (remastered) (Bugbear Battle)

So it must be a bug with the Player, no ?