FAQ: AppleScriptObjC and Yosemite (OS X 10.10)

AppleScriptObjC Yosemite warning

This is the warning dialog you will see when you try to run a script that uses AppleScriptObjC and you are running Yosemite.

If you attempt to run a script that includes AppleScriptObjC code, or uses a library that includes AppleScriptObjC code, and you are running OS X 10.10, you will see a dialog like the one shown above. If you are wondering what to do when confronted with it, read on.

The problem stems from a bug in AppleScript that was fixed in El Capitan, OS X 10.11. In simple terms, sometimes AppleScript tries to free up some memory no longer needed, not realizing that it had already been freed and potentially used for something else. The result is usually a hard crash.

This AppleScript memory house-keeping (garbage collection) can occur periodically, so the initial release of memory could have happened some time before any crash. And in some scripts there may be no need for AppleScript to do any garbage collection until they have been run several times, so tracking down the actual trigger is near impossible.

What we do know is this: the bug seems to be triggered not by running the script, but by documenting what is happening. It is therefore a problem that shows up in script editors. And the more an editor tries to show you what is happening in a script, by displaying descriptive results or allowing you to step through scripts, the more likely the bug will occur. The bug can be triggered when a script is run in Apple’s Script Editor, but it happens less frequently there because Script Editor makes little effort to document what’s happening with AppleScriptObjC.

There is no particular code or class that triggers the bug, although it is more likely to occur if you run a script repeatedly without recompiling. You are also more likely to trigger it if you use the repeat with x in form of repeat loop with a list (not array) of Cocoa objects. Beyond that, we cannot offer any guidance; that’s the nature of the problem.

So what happens if you press the Continue button in the warning dialog? Script Debugger may crash at some stage while running the script. When that happens, any data the script is dealing with will be lost. **Do not press the Continue button unless you are willing to take the risk, and any data you are dealing with is not live data, but rather a copy for testing. **

In fact, the latter is good advice when testing any script that uses AppleScriptObjC — in the words of Apple’s Release Notes for AppleScript: Using Objective-C frameworks from AppleScript provides many new and exciting opportunities to crash the host process.