• 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
AppleScript running under Cocoa - major speed issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AppleScript running under Cocoa - major speed issue


  • Subject: AppleScript running under Cocoa - major speed issue
  • From: Steve Cronin <email@hidden>
  • Date: Sat, 20 Oct 2007 10:46:22 -0500

Folks;

I have a Cocoa app that has some iPhoto integration.
Since there is no Cocoa API for iPhoto, like there is for AddressBook, the only way I know to do this is through AppleScript.
Any other ideas here would be appreciated....


BTW: This is OS 10.4.10; Xcode 2.4.1; iPhoto 6.0.6; 2 GHz C2D

The Cocoa app has a compiled AppleScript which I call into for the various handlers with the parameters I need.
This is working well in every other case.
For the record it looks like this:
thisResult = [[[NSApp delegate] asEngine] executeAppleEvent:[ASCode callSub:@"getiPhotoImage" params:
[NSAppleEventDescriptor descriptorWithString:path],
nil] error:&errorDict];



However I have a case where it is taking 25 seconds to execute a single AppleScript statement!
This same statement has sub-second response when executed in the Script editor.
If I simulate the Cocoa calls with various handlers in the Script Editor everything is fine - performance is fine!


I have logging statements embedded in both Cocoa and AppleScript which have allowed me to hone in on the offending statement.

The result is perfectly repeatable. Every time it takes 25 SECONDS to execute the following:
[Cut and Paste this into a Script Editor - should work fine...(just change the myPath variable to make it work or fail]
[You can also save it as a run-only application to see the performance is that incarnation...]


set myPath to "/Users/SOMEUSERNAME/Pictures/iPhoto Library/Originals/ 2007/Roll 1/SOMEPICTURENAME.jpg"
tell application "iPhoto"
try
set thisPhoto to first photo whose image path is myPath -- << THIS IS THE CULPRIT
if thisPhoto exists then
display dialog "'" & name of thisPhoto & "' was found"
else
display dialog "This branch will never occur"
end if
on error e number n
if n = -2753 then
display dialog "Requested photo was NOT found"
else
display dialog "Error: " & n & " - " & e
end if
end try
end tell


I know it may seem like an AppleScript issue but the shoddy performance is a ONLY when it is run underneath a Cocoa app so I am under the impression that there is something Cocoa-related which is causal.
I don't believe any of our friends on the AppleScript list will have anything helpful, however I AM cross-posting to AppleScript list to see what I can find....


Could anyone shed any light on what is going on here?
Is there a hidden AppleScript feature like iTunes' 'fixed indexing' which might improve response times?
Why does it work in Script Editor or as a AS run-only application?


Thanks for any and all thoughts!
Steve
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: AppleScript running under Cocoa - major speed issue
      • From: Alastair Houghton <email@hidden>
  • Prev by Date: detecting when an app is beach-balling
  • Next by Date: Re: What is a task?
  • Previous by thread: [OT] Re: detecting when an app is beach-balling
  • Next by thread: Re: AppleScript running under Cocoa - major speed issue
  • Index(es):
    • Date
    • Thread