Thank you for the details! I will make a note of this and try to get it fixed for the next beta update. I think I can arrange for the same “just in time” updates to the hierarchy that happen when you click the menu or use a keyboard shortcut, to happen when invoking via script, too.
Hey folks - getting pretty close to a public beta (casting a wider net than this forum). I really appreciate all the early feedback. I’ve just updated the beta to 3.0b31 which includes a substantial overhaul to the way I handle triggering scripts from keystrokes. I am now getting back to the “roots” of FastScripts, trying to make response time as quick as possible. To that end I’m reusing script runner processes to avoid the overhead of launching a separate process every time you invoke a script. Should be a noticeably better experience especially for quick, repetitive script operations.
You can download 3.0b31 here by selecting “Check for Update” from the FastScripts 3 beta, or by downloading directly here:
https://redsweater.com/fastscripts/FastScripts3.0b31.zip
Thanks again!
Daniel
Sounds good. Any chance of a command to quit the process so the next run script launches a new one? I’m thinking in terms of flushing cached libraries and frameworks, as well as cleaning up from ASObjC’s tendency to leak memory like a sieve.
I’ll definitely consider that, but bear in mind that quitting FastScripts and relaunching it will cause all the associate script running processes to be terminated and recreated. I think what I’ll probably end up doing is trying to fairly aggressively “age out” the script runners so that there is always one available, but maybe they only run a few scripts before they get terminated and a fresh one takes its place.
Update: This was solved after a restart, but seems to be happening fairly often…
I’m using Shane’s RegexAndStuffLib library available here (Freeware | Late Night Software). It’s installed in my user library, and I’m running macOS 10.15.7 with FastScripts 30.b31.
My script works from Script Debugger and Script Editor, but fails when run from FastScripts with the following error:
Error Number: -1708
NSRegularExpression doesn’t understand the “regularExpressionWithPattern_options_error_” message.
Perhaps this isn’t a new thing, because I opened FastScripts 2.8.3 and get the same error. However, this did not appear to be a happening a few months ago, perhaps in an earlier version of FastScripts v2.
Here’s a simple script for testing:
use AppleScript version “2.4”
use framework “Foundation”
use framework “Quartz”
use scripting additions
use script “RegexAndStuffLib” version “1.0.7”
set someText to “This is a simple test”
set thisResult to regex search someText search pattern “(.)simple.” capture groups 1
display dialog thisResult
Thanks, Ray. I’m looking into this now. I haven’t been able to reproduce the bug but based on the symptoms you describe it makes me wonder if the scirpt runner is somehow getting “tainted” by another script that you’ve run previously. If you can narrow it down at all that would be helpful. I am assuming when you reproduced it in 2.8.3 it didn’t happen first thing after launching the app?
Update: I Googled for the error you’re seeing and, what do you know? The very issue was covered extensively on these forums: Strange ASObjC Error When Running RegexAndStuff Lib from FastScripts It sounds like your experience is very much like what is discussed in that post. Hopefully the lengthy examination of the issue will help you, too.
I’ll keep an eye on it. But it did happen in 2.8.3 when I first launched the app. In other words, quit the beta, launched 2.8.3, ran script, and error occurred immediately.
And just to be clear, the problem didn’t go away until a full system restart. Quitting and relaunching FastScripts itself did not help.
Ah, I see! Well, it sounds so close to the description of that other thread that I think the advice from @ShaneStanley, @ccstone, etc. will certainly be valuable. I’m afraid I don’t really understand the underlying issue myself too well.
Just FYI to all regarding the previous thread: I’m not using a SymLink. The library is in the usual User>Scripting Libraries folder.
The script is saved as .scpt, not a bundle. I do use Dropbox, but the script is in the user library Scripts folder, so not on Dropbox.
So other than the error being the same, I’m not seeing anything that applies from the previous thread.
@rayrobertson one thing to try: you can rename one version of FastScripts, say FastScripts 3
, and then have both versions running. It would be interesting to know if the problem, if it appears again, happens in both versions.
(And yes, your issue does sound different from that in the other thread.)
@ShaneStanley It’s probably worth noting that the actual script will always be running in a process named “RSScriptRunner”, so I don’t know if the name of the host app is likely to matter so much. But I wonder if having multiple apps on the system, sometimes running in tandem, and all invoking scripts, could cause the symptom Ray is reporting?
The renaming is really so both versions can live in /Applications.
I don’t think so. I mean, I suspect a lot of FastScripts users still also have Apple’s Scripts menu still running too (for no particular reason).
@rayrobertson could also try removing the unneeded use framework
statements from his test script, although I can’t see why it would matter. But it might help narrow things down further.
I keep thinking that the one thing we know about script libraries is that AS caches them on a per-instance basis. I presume you’re using the runner’s default instance, but I wonder whether it would be worth trying with a new instance.
Thanks for the tip. In spite of how much weird stuff I know about AppleScript and making a tool like FastScripts over the years, I’m still a little foggy about some of these finer points. @rayrobertson if you want to drop me a line at support@redsweater.com, I can experiement with making versions of FastScripts that behave differently and see if we can get to the bottom of this!
@ShaneStanley It’s 1.0.7. I’ll see if I can get this to occur again and check out the other suggestions.
I just released FastScripts 3.0b32 which includes a few substantial changes:
- Running scripts now appear in the FastScripts menu and can be force-stopped
- Scripts are no longer run on the same script runner process. A fresh process is used for each invocation
- Fix the ordering of items in the recent scripts submenu so that most recent scripts are at the top
“Check for Update” from a previous beta, or download directly here: https://redsweater.com/fastscripts/FastScripts3.0b32.zip
I’ be curious @rayrobertson if this change to run scripts in a new process every time affects the behavior you’re seeing with RegexAndStuffLib at all.
Thanks, Daniel.
I have not been able to reproduce the error condition yet. I’ll keep an eye on it. FastScripts b32 does seem to be running scripts much faster. I repeated the call to the regex library 10,000 times and it is taking 51 seconds total each time. That’s comparable to a “fresh” launch of SD8 beta. However, SD seems to run in to a low memory state at times, and the same script took 250 seconds (fans kicking on, SD appearing to lock, but not quite).
That’s all very unscientific, though, as with earlier testing both SD and FS appeared to wildly vary from run to run in how long it would take to complete—not sure if that issue is isolate to library calls, or RegEx libraries call only, or vanilla scripts as well. For now, though FS, seems consistent.
Feedback: I’d rather not have “Stop script” in a submenu. Any chance you could just make the menu item “Stop ScriptNameHere” so we can choose it quickly. It would be even better if that menu item were at the very top of the FS menu. And, best of all, if we could have a keyboard shortcut to stop the “last invoked script” or something like that.
And now, getting really greedy, could you make the FastScript menu icon flash or something while a script process is running?
Thanks.
Thanks for the additional feedback and speed sanity check. The “Stop Script” UI is very preliminary. I expect to amend those menu items to show progress information, and probably support a UI to cancel the script in a custom view. Not sure yet, but just wanted to get something functional in ASAP.
I don’t know if I anticipate that many people wanting to have a keyboard shortcut to kill the last script they ran, but your suggestion makes me think it would be a great idea to support accessing and canceling running scripts via FastScript’s own scripting dictionary. With this, you could easily add a script to provide just that functionality.
I do have some thoughts about showing activity in the icon somehow while scripts are running. I’ll probably get to that before the final release.
If you’re looking for work , I think it would be useful for FastScripts to be able to call a script’s open
handler. So if it detected that a script has an open handler, it would send an event to the Finder to get the current selection, and then pass that in an open
event to the script.
I’d envisage one of two things:
- Scripts with an
open
handler would appear with some signifying icon in the menu; or - Some key combination would switch between showing/calling scripts with
open
handlers versusrun
handlers.
I know it’s easy enough to have scripts get the selection from the Finder themselves, but I think the real value here would be making it obvious in the UI what’s required for a particular script.