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

system unresponsive during script execution of Status Menu app #115

Open
michaelcinquin opened this issue May 30, 2018 · 8 comments
Open

Comments

@michaelcinquin
Copy link

Hi

during the execution of the script called by a Status Menu App, the system becomes unresponsive. User input in Terminal becomes impossible, one has to ssh into the box to kill the script.

Steps to reproduce:

  • create a one line ~/sleep.sh : sleep 10
  • create a Platypus Shell script with interface "Status Menu"
  • run app --> system is unresponsive for 10 seconds

The problem doesn't happen with other user interfaces.

This is using Platypus 5.2 1008, running on 10.12.6

hope this is something you could fix?

@sveinbjornt
Copy link
Owner

sveinbjornt commented Jun 1, 2018

Hello there and thank you very much for the donation!

The problem here is that the script is immediately run when the status item is pressed. The Platypus app then waits for the script to finish executing on the main thread, parses the output and presents the menu. If the script locks up or goes to sleep, the app just merrily waits for it to finish none the less, which locks up the interface.

Now, this wouldn't normally affect the rest of the system UI but Apple implements Status Items in such a way that they are "part of the interface" and can therefore lock up the main system UI thread.

There are two solutions I see to this:

a) Add a hard timeout limit for script execution (a few seconds), after which the script process is killed and no menu shown (or maybe a timeout error message)

b) It may be possible to try to update the menu asynchronously, i.e. launch the script, show the empty menu, parse output from script in background and then add menu items on the main thread as the script output is received and parsed. This is likely to be tricky to do in a reliable way. However, it's something worth looking into. Some Apple-provided SystemUIServer menus (e.g. Time Machine) do update their contents dynamically. The Status Menu output mode has always been a bit flaky due to the special nature of the Status Item API, but maybe there are ways around it.

What kind of scripts are you running that take such a long time to execute? For long-running processes, Status Menu output mode is unlikely to be what you want.

@michaelcinquin
Copy link
Author

hello,

thanks for the reply. I'm running scripts which do network requests to show status, some of which can take a bit of time. Status menu output is really what I'm after.

Would it be possible to send a notification from a background thread to the main thread after the script exits, and then after it has received the notification the main thread would read the output of the script. In the meanwhile, the main thread could show "processing…" or something like this?

@sveinbjornt
Copy link
Owner

I just threw together a test project which shows that this is definitely possible. This feature is now on the Platypus 5.3 roadmap.

Would you like me to send you a new ScriptExec binary with this feature as soon as it's working reliably? It may be months before I release another version of Platypus.

@michaelcinquin
Copy link
Author

perfect! Sure, I would love to receive a new ScriptExec binary.
Many thanks

@m0ose
Copy link

m0ose commented Jan 21, 2022

What is the status on this? Is there a special way to write the script to make the menu bar responsive?

@sveinbjornt
Copy link
Owner

I'm afraid you'll have to wait for Platypus 5.3.

@huyz
Copy link

huyz commented Jun 12, 2022

I'm afraid you'll have to wait for Platypus 5.3.

Did you make a newer version of Platypus. It seems we've been at Platypus 5.3 for several years already

@akwangl
Copy link

akwangl commented Oct 17, 2023

Can I add an exit button?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants