Post-Yosemite script-running performance hit

Has anyone else seen Applescripts running an order of magnitude slower from KeyBoard Maestro after installing Yosemite ?

A script which I regularly used from KM, and which still executes in under 2 seconds from Yosemite Script Editor (or as a .workflow from inside Automator), now takes c. 20 seconds if launched from Keyboard Maestro.

Clue: it involves various bits of inter-process communication: Applescript wrapper gets data through .js from FoldingText, and then communicates via AS with Reminders.app
FTMakeOrUpdateReminders at https://github.com/RobTrew/txtquery-tools/blob/master/links%20between%20plain%20text%20and%20Reminders/FTMakeOrUpdateReminder.applescript

Despite the fast performance when running in the Script Editor environment, I notice that:

  1. a similarly dramatic slowing down is happening when launched shell osascript command lines and script menus
  2. that all 3 of the slowed environments initially threw up an automation permission dialog when the script was first run from them

Any thoughts on what is happening, or on a solution ?

I don’t really want to abandon my KM shorcuts and launch from Script Editor all the time :confused:

Rob

Not sure if this is relevant, but I notice in the Console log a failing assertion which seems to include a

/Users/peter/...

path, which doesn’t match $HOME on my system

20/10/2014 22:41:34.073 Keyboard Maestro Engine[439]: Keyboard Maestro Engine: Assertion Failed: tempScriptHolder.shellCommand,  file: /Users/peter/Keyboard Maestro/Project/Source/Actions/AExecuteRootScript.mm:48, value: 0

The assertions refer to lines of source code where the problem occurs, hence they are always /Users/peter/ paths (they are simply constant strings stored in Keyboard Maestro).

That assertion indicates Keyboard Maestro could not create a temporary file path, which really should never happen.

Under what conditions are you sing that assertion?

Running this inter-app automation script (FoldingText.app, Reminders.app) from an Execute Applescript Action:

Runs as fast as under Mavericks in:

  • Yosemite Script Editor
  • Yosemite Automator (run as workflow)

but now dramatically slowed down under Yosemite (and throws up automation permission dialog on first run) if launched from:

  • Keyboard Maestro
  • Services menu (Automator generated service)

( Similarly slowed on Yosemite if run from Bash osascript command line)

Another pair of Console messages which could be extraneous but happened to coincide in time with first KM launch of the script this morning:

21/10/2014 09:32:30.455 com.apple.xpc.launchd[1]: (com.apple.imfoundation.IMRemoteURLConnectionAgent) The _DirtyJetsamMemoryLimit key is not available on this platform.
21/10/2014 09:32:31.094 com.apple.xpc.launchd[1]: (com.apple.CoreLocationAgent[1881]) Endpoint has been activated through legacy launch(3) APIs. Please switch to XPC or bootstrap_check_in(): com.apple.CoreLocation.agent

I think that Console message may be a false trail – unconnected to the script slowing, except by a coincidence of time.

I just managed to trigger a bunch of those assertion fails by trying to run an ‘execute script file’ action after moving the referenced script without updating the Script file entry in the KM action.

21/10/2014 10:28:58.258 Keyboard Maestro Engine[439]: Keyboard Maestro Engine: Assertion Failed: tempScriptHolder.shellCommand,  file: /Users/peter/Keyboard Maestro/Project/Source/Actions/AExecuteRootScript.mm:48, value: 0
21/10/2014 10:29:09.399 Keyboard Maestro Engine[439]: Keyboard Maestro Engine: Assertion Failed: tempScriptHolder.shellCommand,  file: /Users/peter/Keyboard Maestro/Project/Source/Actions/AExecuteRootScript.mm:48, value: 0
21/10/2014 10:29:29.315 Keyboard Maestro Engine[439]: Keyboard Maestro Engine: Assertion Failed: tempScriptHolder.shellCommand,  file: /Users/peter/Keyboard Maestro/Project/Source/Actions/AExecuteRootScript.mm:48, value: 0

Keyboard Maestro executes scripts via osascript, so if that is slow to execute the script, then the script will be slow to execute from Keyboard Maestro. It doesn’t help you, I know, but it does narrow down what you need to look at - figure out why or how running the script via osascript is slow.

Yes, the assertion could happen in the case where you have specified a file and the file doesn’t exist, so that’s fine and safely ignorable.

Thanks Peter – Yosemite seems to have opened a big gulf between execution from Script Editor.app/Automator.app and anything that depends on osascript for inter-app communication.

Still slower than SE/AU, but c. 4x faster than osascript for app automation is now to use open application path at the command line, having saved a script as an .app, added it to the list under Sys Prefs > Security & Privacy > Privacy, and logged out and then back in …

A pity, though, to have to relocate automation scripts out of Keyboard Maestro …