• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Executing AppleScripts in multithreaded Cocoa App
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Executing AppleScripts in multithreaded Cocoa App


  • Subject: Executing AppleScripts in multithreaded Cocoa App
  • From: Martin Halter <email@hidden>
  • Date: Sat, 09 Jul 2011 17:11:21 +0000 (GMT)

Abstract:
Sending AppleEvent or executing AppleScripts on any thread in a parallel (asynchronous) manner from a Cocoa App.

Dear List, I'm posting this here as i think it's the most appropriate one. If not, please tell me.


Symptom 1 Crash:
Reading the documentation, i'm told that executing AppleScripts on any thread is supported since 10.6. After shipping my app in early versions we had crashes sent back to us reading that something in this area is not working as described. We were doing it with something in the line of TCallScript using executeAppleEvent.


Symptom 2 Hang (spin):
After these reports, we changed the code so the app only sends from main-thread. After shipping this version, he had hang-reports reading that AppleScript is blocking the main thread. We do it now with NSAppleScript executeAndReturnError


Both symptoms are not reproducible. No pattern in targeted Apps, no pattern in OS-Version, CPUs with 2 or 8 cores seem less affected than ones with 4.

One idea: the first symptom is caused by GCD/NSOperationQueue threads that don't have a running runloop. Second symptom is caused by sending new AE before first return. 

I'd like having it as robust as possible. 


Questions:
* Does anyone has experienced the same thing? I found discussions on this subject but all pre Snow Leopard.
* Is having a dedicated NSThread for all AE-Communications the recommended way of doing it?
* Would you recommend having another thread monitoring the AE-Thread and stopping it when spinning for too long? (watchdog polling every second?)

* Are there limitations to sending AE from different threads parallel (not waiting for the first to answer)?

* What's the mystery behind AESendMessage and an answer port? Is it a recommended way to go?
* Should we even consider SBApplication (Scripting Bridge) to make it more robust?


Thanks everybody for any answers or directions

best regards

mahal


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Executing AppleScripts in multithreaded Cocoa App
      • From: David Dantowitz <email@hidden>
  • Prev by Date: TIME TO GMT and Summer time
  • Next by Date: Re: TIME TO GMT and Summer time
  • Previous by thread: Re: TIME TO GMT and Summer time
  • Next by thread: Re: Executing AppleScripts in multithreaded Cocoa App
  • Index(es):
    • Date
    • Thread