AppleEvents errors in 10.13

I'm the developer of SmashTunes (an app to control iTunes and Spotify). Since the latest beta of 10.13, I'm seeing a lot of errors being logged:


10759711: Error #17  (os/kern) invalid right attempting to add send right to port ( port:33051/0x811b rcv:1,send:0,d:0 limit:5).
AppleEvents: received mach msg which wasn't complex type as expected in getMemoryReference.


SmashTunes use ScriptingBridge for its communication with iTunes and Spotify. I'm suspecting this may have to do something with my entitlements file (which I think should be correct). The "funny" thing is, that the app is still functioning correctly (although a bit slow). So, the AppleScript is correclty executed by both Spotify and iTunes.


Anyone seen this before?

Replies

There’s a few things to note here:

  • Your script seems to be actually working; the issue is that you’re not capturing the results of the

    log
    event.
  • That problem seems unrelated to the

    getMemoryReference
    log messages. For example, if you remove the
    log
    commands from your script, you still see these log messages.
  • To my mind it would be better to run the AppleScript within your process rather than relying on

    osascript
    . You can do this with the code below.

    Note This code looks for a playground, not a workspace.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
import Cocoa

var script: NSAppleScript = {
    let script = NSAppleScript(source: """
        tell application "Xcode"
            set docs to every workspace document
            repeat with doc in docs
                set str to name of doc as string
                if str is "MyPlayground.playground" then
                    set thePath to path of doc
                    return thePath as string
                end if
            end repeat
        end tell
        return ""
        """
    )!
    let success = script.compileAndReturnError(nil)
    assert(success)
    return script
}()

func main() {
    var error: NSDictionary? = nil
    let resultMaybe = script.executeAndReturnError(&error) as NSAppleEventDescriptor?
    guard let result = resultMaybe else {
        print("AppleScript failed; need to look in `error`")
        return
    }
    guard let resultStr = result.stringValue else {
        print("AppleScript returned something of the wrong type")
        return
    }
    guard !resultStr.isEmpty else {
        print("AppleScript didn't find our playground")
        return
    }
    print(resultStr)
}

main()

As I mentioned back on 18 Dec, there are a bunch of interrelated issues covered by this thread. One of those issues is the log message:

AppleEvents: received mach msg which wasn't complex type as expected in getMemoryReference.

A developer was worried about this message and so they opened a DTS tech support incident to verify whether it’s harmful or not. I discovered the underlying cause of this message and I’m satisfied that it’s just log spam, that is, it’s annoying because it fills up the log with junk but it has no other deleterious effects.

There’s a bug on file (r. 33758979) requesting that we remove this log spam.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"