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

Applications sometimes silently don't launch #22

Closed
turtlewit opened this issue May 3, 2020 · 33 comments
Closed

Applications sometimes silently don't launch #22

turtlewit opened this issue May 3, 2020 · 33 comments
Labels
bug Something isn't working

Comments

@turtlewit
Copy link
Contributor

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:

  1. The first time using the launcher after starting the system.
  2. After not using the launcher for a few hours.

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:

  • Arch Linux (linux 5.6.4-arch1-1-fsync)
  • Shell: zsh 5.8 (sway-launcher-desktop of course launches with bash 5.0.16)
  • Terminal: alacritty 0.4.2-dev (f7561850)
  • Using the aur package sway-launcher-desktop 1.2.1-2
  • Sway config for launching it: bindsym $mod+d exec alacritty -t "sway-launcher-desktop" -d 110 36 -e env TERMINAL_COMMAND="alacritty -e" /usr/bin/sway-launcher-desktop
  • This specific setup is my desktop, but the bug also happens on my laptop with a very similar setup.
@Biont
Copy link
Owner

Biont commented May 3, 2020

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?

@Biont Biont added the bug Something isn't working label May 3, 2020
@NullSense
Copy link

NullSense commented May 4, 2020

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.

@turtlewit
Copy link
Contributor Author

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?

@turtlewit
Copy link
Contributor Author

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.

@Biont
Copy link
Owner

Biont commented May 9, 2020

Good finding! I will try to get involved soon, but I am currently occupied by my new family member.

@turtlewit
Copy link
Contributor Author

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.

@NullSense
Copy link

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.

@Biont
Copy link
Owner

Biont commented Jun 7, 2020

Are you suggesting it is getting worse over time?

@NullSense
Copy link

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.

@jkehler
Copy link

jkehler commented Jun 15, 2020

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.

Biont added a commit that referenced this issue Jun 19, 2020
…information is directed to file descriptor 3 and can be dumped using `./sway-launcher-desktop.sh 3>> ~/sway-launcher-desktop.log`
@Biont
Copy link
Owner

Biont commented Jun 19, 2020

@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.

@jkehler
Copy link

jkehler commented Jul 9, 2020

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.

@Biont
Copy link
Owner

Biont commented Jul 9, 2020

@jkehler just to be sure, you are using the latest master?

@turtlewit
Copy link
Contributor Author

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.

@jkehler
Copy link

jkehler commented Jul 13, 2020

I used the sway-launcher-desktop-git AUR package. Not sure if this is based on master or not?

@Biont
Copy link
Owner

Biont commented Jul 13, 2020

@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.

@Biont
Copy link
Owner

Biont commented Jul 28, 2020

@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?

@turtlewit
Copy link
Contributor Author

@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

@Biont
Copy link
Owner

Biont commented Jul 28, 2020

@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.

@NullSense
Copy link

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 🤷 . Will be moving to a wayland rofi clone.

@Biont
Copy link
Owner

Biont commented Aug 24, 2020

Sorry to hear that. Were you able to grab any logs with the latest few commits? And have you tried deleting your history file?

@NullSense
Copy link

Unfortunately I never set up the logging mentioned here, but I did try uninstalling and reinstalling (Arch AUR).

@s-hamann
Copy link
Contributor

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...

@Biont
Copy link
Owner

Biont commented Aug 28, 2020

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 &)

@s-hamann
Copy link
Contributor

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'

@Biont
Copy link
Owner

Biont commented Sep 1, 2020

I searched around a bit and found this thread which discusses a few approaches. Can you try if things are improving @s-hamann ?

@NullSense
Copy link

NullSense commented Sep 3, 2020

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.

@s-hamann
Copy link
Contributor

s-hamann commented Sep 3, 2020

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.

@Biont
Copy link
Owner

Biont commented Sep 4, 2020

Does it still happen with the version I had already committed?

@NullSense
Copy link

@Biont fe2e71e fixed it for me. I would close this issue.

@ghost
Copy link

ghost commented Sep 5, 2020

fe2e71e fixed it for me.

@Biont
Copy link
Owner

Biont commented Sep 5, 2020

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

@Biont
Copy link
Owner

Biont commented Sep 6, 2020

1.3.0

@Biont Biont closed this as completed Sep 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants