Re: AppleScript Studio Application - Annoying Delays
Re: AppleScript Studio Application - Annoying Delays
- Subject: Re: AppleScript Studio Application - Annoying Delays
- From: Paul Scott <email@hidden>
- Date: Tue, 2 Jun 2009 09:36:53 -0700
I may have solved this problem.
First, I eliminated the "POSIX path of file" delays, by moving the
file name conversion code out of the processing logic driven by the
"on clicked" handler, and into the initialization logic driven by the
"on activated" handler (before any background process runs).
That change, however, did not eliminate the delay at application
termination -- which only occurs after a background process has run.
This AppleScript Studio application runs "hdiutil" as a background
shell command which I suspected might be causing both the termination
delay and "POSIX path of file" delay. So, to test the hypothesis, I
replaced "hdiutil" with another long running command -- i.e., "find / -
type d" -- and the problem disappeared. Then, I restored the "hdiutil"
command and issued a "renice" on the background process. No more
delays, even after dozens of tests, which previously would have
produced half as many delays.
I find this strange, because the AppleScript Studio application does
not do any work -- except in the "on idle" handler to test the pid for
termination -- and will not quit until the background process
terminates, either on its own or manually via "kill". Perhaps the
AppleScript Studio application has some queued up messages that don't
get processed immediately without the "renice" on the background
process? Doubtful, because I could see the "on idle" handler running
as scheduled. Nevertheless, the change seems to have mitigated, if not
eliminated, the problem.
I will continue testing, but so far ...
Paul
On Jun 1, 2009, at 10:16 PM, Takaaki Naganoya wrote:
I have two questions.
(1) Does the AppleScript Studio application show such a strange
behavior on another machine ?
(2) Is there any event mis-match between AppleScript code on Xcode
and Interface Builder ?
On 2009/05/30, at 7:58, Paul Scott wrote:
I've written an AppleScript Studio application that exhibits a
strange behavior on quit. Very often it will not immediately quit
when it should, but will hang for a few seconds or more, and then
eventually quit. To debug the problem, I put a "display dialog" as
the *last line* of the "on will quit" handler, and it always (100%
of the time) displays *immediately* on quit, but when I dismiss the
dialog the application spins the beach ball for awhile before
quitting. Of course, the delay happens whether or not the "display
dialog" is there; it was inserted just to prove the point.
Any idea what could be causing this?
All my other AppleScript Studio applications do not exhibit this
behavior, even those with the same basic structure -- that is, it
runs a shell script in background when a button is clicked, and
uses the "on idle" handler once per second to test whether the
process has ended, then advances to the next file to process.
There is a caveat that might be of interest in resolving this
problem. I have noticed that "POSIX path of file" also hangs
periodically in the same application for a few seconds; it runs in
the "on idle" handler. As far as I can tell, no other lines of code
experience any delay whatsoever.
So far, I've only tested this on a MacBook Pro (2.16Ghz Intel Core
Duo), which has no third-party software on it; I recently reloaded
a fresh copy of Mac OSX Leopard, installed all the software
updates, and then installed the most recent Developer tools. Clean
system.
Why the annoying delays? and how to get rid of ''em?
Paul
--
Takaaki Naganoya
Piyomaru Software
http://piyo.piyocast.com
email@hidden
PiyoCast Web (Podcasting with Music!)
http://www.piyocast.com
Free AppleScript Library "AS Hole"
http://www.piyocast.com/as/
_______________________________________________
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