Closed turtlewit closed 4 years ago
Hi, thanks for the bug report.
I think I have experienced what you are describing, but it's very rare (like once in 3-4 days rare) and I have always written it off as something caused by external factors. But your description does sound familiar so it's worth trying to get to the bottom of it. Don't quite know how, tough, so I guess the first thing that feels right is the addition of some tools to help debugging, ie. logging some stuff to stderr
and maybe capturing some stuff from other processes into it.
Do you have any other ideas?
I have also experienced this, also on Arch, running zsh and alacritty. I could not identify any repeatable factors, but hopefully this helps.
EDIT: I noticed this happens disproportionally more while trying to launch firefox.
I set up some logging in the run_desktop()
function as such:
function run-desktop() {
echo "Running Command $(date)" >>sway-launcher.log
bash -xc "$("${0}" generate-command "$@")" >>sway-launcher.log 2>>sway-launcher.log
}
However, after doing so, I have yet to experience the bug again. I had a similar experience during my first attempt at debugging this. This leads me to believe it may be timing-sensitive in some way, or is affected by a race condition, but I'm not familiar enough with the script to know if that's even possible.
For now I'll keep the logging active and see if I can eventually experience the bug again. Would you recommend anything else to write to the log?
Not sure if this would be any help, but it seems like run-desktop
is never run when the bug occurs, so it exits earlier in the script.
Good finding! I will try to get involved soon, but I am currently occupied by my new family member.
No worries, there's no rush! It's not a huge inconvenience, so I don't mind if fixing it takes a while (especially as it's so elusive). I'll try and add some more print statements to see where it exits.
Launching is almost completely broken for me at this point, it has become quite unusable. Launching custom Firefox profiles always fails and some programs also never launch, or some take multiple tries to launch.
Are there any points in the code that I should take a look at? I'd like to fix this ASAP.
Are you suggesting it is getting worse over time?
I'm not sure if it's getting worse over time, but there was a time when I did use the launcher that the desktop files were launching properly.
I have also been having the same problem. It's been driving me nuts sometimes where I have to try to launch the app a 2nd time. I also can't find any sort of pattern to it.
@turtlewit @NullSense @jkehler
I have added some very basic debug information that can be dumped to a file using ./sway-launcher-desktop.sh 3>> ~/sway-launcher-desktop.log
. I hope this helps us getting to the bottom of this. If you add the output redirection to your wm configs, you should be able to pull up a log when it happens. Should be easy to add more info if needed.
I tried adding the logging redirect but it doesn't seem to output anything. I've already had several failed app launches where nothing happened yet the log file remains completely empty.
@jkehler just to be sure, you are using the latest master?
I am on the latest master and I don't get any output. This is my sway command to launch it:
bindsym $mod+d exec alacritty -t "sway-launcher-desktop" -d 110 36 -e env TERMINAL_COMMAND="alacritty -e" /usr/bin/sway-launcher-desktop 3>>/home/kat/tmp/sway-launcher.log
Though it seems to not output anything when launched manually like your example.
I used the sway-launcher-desktop-git
AUR package. Not sure if this is based on master or not?
@turtlewit looks like it's piping alacritty to the file, instead of sway-launcher-desktop. I'm seeing the same problem here, but it does work in isolation (script just being run from terminal itself). I hope this can be solved by quoting/escaping the full command so it all gets passed inside alacritty's -e
parameter
@jkehler Yes it is based on master, but it will not update by itself when new commits are made.
@jkehler @turtlewit I now provide the file descriptor 3 in a different way which seems to resolve the issue with it not generating any output. Could you please check again?
@Biont Yes, I now get output in the log. This was the output on a failed launch (of Godot in this case).
Starting launcher instance with the following providers: desktop command
Launching command: /usr/bin/sway-launcher-desktop run-desktop '/home/kat/.local/share/applications/godot.desktop'
If it might help, here's contents the desktop entry I tried to launch: https://pastebin.com/m2njZgwF
@turtlewit Interesting, it should have logged Generated Launch command from .desktop file: godot
but didn't. This leads us to the generate-command
function. Not quite sure what to make out of this, because -of course- it all works without issue when I test it.
I tried to catch the stderr of generate-command
in my latest commit, but there probably isn't anything that writes to it yet.
Unfortunately this launcher has become completely unusable for me, 70% of the time programs fails to launch for me. I looked through the code multiple times, but don't have enough experience with it to help :shrug: . Will be moving to a wayland rofi clone.
Sorry to hear that. Were you able to grab any logs with the latest few commits? And have you tried deleting your history file?
Unfortunately I never set up the logging mentioned here, but I did try uninstalling and reinstalling (Arch AUR).
Here's what's logged on a failure:
Starting launcher instance with the following providers: power desktop command
Starting launcher instance with the following providers: power desktop command
Launching command: sway-launcher-desktop.sh run-desktop '/usr/share/applications/firefox.desktop'
On success, I get:
Starting launcher instance with the following providers: power desktop command
Starting launcher instance with the following providers: power desktop command
Launching command: sway-launcher-desktop.sh run-desktop '/usr/share/applications/firefox.desktop'
Searching for pattern: ^\\[Desktop Entry\\]
Generated Launch command from .desktop file: firefox
Since logging Searching for pattern
is about the first thing in generate-command
, it seems that the error is either in the last line of sway-launcher-desktop.sh
, or somewhere before generate-command
is called (probably even before run-desktop
).
I just added a few more debug lines to my instance and will report back if that produces anything helpful...
Thank you @s-hamann
I also feel that it never even reaches run-desktop
, mostly because I there should be more logs before something breaks it it actually went in.
So something's probably odd with the way commands are handled in (exec setsid /bin/sh -c "${COMMAND}" &>/dev/null &)
So something's probably odd with the way commands are handled in
(exec setsid /bin/sh -c "${COMMAND}" &>/dev/null &)
I can confirm that now. I added a debug line near the very top and the log's last line is still
Launching command: sway-launcher-desktop.sh run-desktop '/usr/share/applications/firefox.desktop'
I searched around a bit and found this thread which discusses a few approaches. Can you try if things are improving @s-hamann ?
I searched around a bit and found this thread which discusses a few approaches. Can you try if things are improving @s-hamann ?
I took a look and just as a raw command it seems to work:
❯ setsid /bin/sh -c "firefox -P Work" >& /dev/null < /dev/null &
[1] 198834
[1] + done setsid /bin/sh -c "firefox -P Work" >&/dev/null < /dev/null
EDIT: The launcher seems to work now as well, I updated my firefox .desktop entries.
I changed the last line to
(exec setsid /bin/sh -c "${COMMAND}" >& /dev/null < /dev/null &)
since that seems to work for @NullSense. I have no idea what's the key difference here, but I'll test that for a while. I can not reliably reproduce the issue, so I can not easily verify that it's fixed. But I'll report back if anything fails to launch for me.
Does it still happen with the version I had already committed?
@Biont fe2e71e
fixed it for me. I would close this issue.
fe2e71e
fixed it for me.
I am so glad we were able to get this sorted out. Thanks for all your help and patience everyone. I will prepare a new release as soon as I find the time
An issue I've been having for a long time is that applications will sometimes silently won't launch. There is no error output when running the launcher from an interactive shell, and the application will almost always launch after simply trying a second time. Subsequent applications launch without issue.
I've been reluctant to file a bug report because it seems like nobody else has experienced this issue, and I have yet to be able to consistently reproduce it. I've identified 2 common senarios where the bug will most likely occur:
I've attempted to debug it a few times, but like I said, I haven't been able to consistently reproduce it (sometimes applications will launch first time after starting the system, etc.) Are there any particular things I should try to get more helpful output or otherwise attempt to debug it?
Specifics of my setup:
sway-launcher-desktop 1.2.1-2
bindsym $mod+d exec alacritty -t "sway-launcher-desktop" -d 110 36 -e env TERMINAL_COMMAND="alacritty -e" /usr/bin/sway-launcher-desktop