Re: spurious timeout on nth Apple event on Snow Leopard
Re: spurious timeout on nth Apple event on Snow Leopard
- Subject: Re: spurious timeout on nth Apple event on Snow Leopard
- From: email@hidden
- Date: Tue, 10 Nov 2009 17:43:23 +0100
On Nov 10, 2009, at 00:35, Hagimeno wrote:
> Hi,
>
> We just installed the final 10.6.2 release and discovered that spurious Apple Event timeout has NOT yet been fixed.
Of course not. There were only 4 weeks since it was reported.
And it only breaks thousands of apps (not only Studio apps, but common ones too), production workflows and other scripts, so it's of course not as important as fixing "a graphics distortion in Safari Top Sites".
> Using Matt script (see below) 10.6.2 stop at about 65530 events in less than a minute.
> Any chance that will be fixed soon?
No. 10.6.2 took a very long time to arrive, despite of the severe bugs in 10.6.1. I bet 10.6.3 will take even longer. Apple collects bugs for long times to fix them in a few but larger bug-fix releases. Single-topic updates are only made if they feel it's absolutely necessary.
I think they do so because it gives the casual user the impression "less bug fix releases = less bugs overall". Likely for the same reason Apple release notes are always more than incomplete about what has been really changed/fixed.
> We need to wait again some months and the 10.6.3?
> We can understand that in others 10.6.x areas there are some bugs that must be fixed but in AppleScript area which bugs are more important that this?
The slowness of Apple events? :)
Seriously, this does by far not affect AppleScript apps/scripts only. Everything that uses Apple events has this problem.
> I would not be boring but we would like to remember to all AS developers that this BUG prevent any customers with new machines equipped with 10.6.x to use any AppleScript, AppleScript Studio or AppleScriptObjC (ASOC) apps to works correctly generating random timeout that can appear after few seconds/minutes.
>
> There is any workaround for continue to work and develop under 10.6.x?
Sure. Make a condition for 10.6 where you call a "find the missing event" handler at the beginning of your script, then proceed. If you know your script will generate more than 65000 events, repeat that handler where necessary.
If your script runs on other machines where you don't have control about how many events other things might produce, call that handler often enough to be halfways sure the missing event doesn't happen in normal script flow.
This will of course make the script even slower than it already is and it clutters your code while still not 100% reliable, but workarounds are part of the AppleScript living, so everything is normal.
Ideally, don't forget to rewrite all "try-on error" constructs which are part of the common script flow. If you don't, the script will not visibly fail, it will just produce wrong results silently. Replace them with "if-then" statements. If not possible complicate & clutter the script logic even further by handling -1712 errors in such constructs.
And if you don't know how much events your script will produce (i.e. unknown amounts of data to process) you could write a logic to count the used events and call the "missing event" handler accordingly. Of course that is still not 100% reliable as you can only count your own events.
I just tried the "tell app finder to count windows"-method and it requires up to 24 seconds on a 2.8 GHz Mac Pro! For just a single "find the missing event" test!
There you have your workaround.
The good thing is that we can now start another performance contest: who will find the fastest method to send Apple events!
In Script Debugger:
tell application "Finder" to count windows --> 24 seconds, unreliable in case Finder is busy and throws a real timeout.
tell application "System Events" to documents folder -- 36 seconds
tell application "System Events" to disk 1 -- far slower
tell application "System Events" to current date -- 16 seconds
current date -- produces Apple events, but the error never occurs
> We are not happy today :-(
As an AppleScript scripter, get used to it. I do AS for 10 years and I'm poor because of the costs for handkerchiefs. And I am really really tired of how Apple threatens AppleScript over all these years. The second-newest chapter in the story is ASOC, where I can't decide of laughing or crying. Exactly the same promises as with Studio. Exactly the same start that Studio had: "Description forthcoming". This really reminds me on every new release of Microsoft Windows: "This time it will be right!"... There was nothing wrong with Studio, except of it's bugs and some missing features (although I understand that debugging in 2009 is a bit much asked for). But history repeats. Instead of fixing bugs and seriously take care of the whole thing "new and great technologies" shall cure the problems. This time really!
No joke: To make a Studio app that is reliable in the outside world about 70% of development time (and code) goes into finding reliable workarounds for AppleScript's bugs, differences in AS versions, missing features, lack of performance + AS bugs in the targeted application.
If we could ignore this, then AppleScript is indeed "a powerful and easy to use language".
From my 10 year-experience I can recommend AppleScript for very tiny things + workflows where you have complete control about the environment. Writing *reliable* apps for the outside world is very challenging and extremely time consuming. I will try RealBasic for future projects, where you have control about the runtime yourself, get complete release notes, a clear language and far more speed & features.
Another con for ASOC: as it requires 10.6 it cripples the user base a lot. If you don't want that you have to support 3 main OS releases, at least for some time where the newest OS just came out. So when 10.8 is out for a half year ASOC becomes a theoretical option (we'll see what it's state is then). Today already known disadvantage: as always, you have to consider ASOC/AS specific things in all the OS releases you want to support... one of the fundamental problems of AS.
http://www.amazon.com/Pure-Cotton-Handkerchiefs-Bakers-dozen/dp/B00006M4B3
Christian
_______________________________________________
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