• 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
Re: Scripting Bridge Strange Pauses
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Bridge Strange Pauses


  • Subject: Re: Scripting Bridge Strange Pauses
  • From: John Nairn <email@hidden>
  • Date: Thu, 16 Sep 2010 22:01:17 -0700

On Sep 16, 2010, at 1:31 PM, Dave Keck wrote:

It is running on main thread. I am not sure how to "profile." I tried "Thread State" in Instruments and it output data, but nothing unusual when the pause occurred. Is that the right tool?

(Sorry, I meant 'sample' instead of 'profile.')

When the loop gets hung up, pause the program in the Xcode debugger
and copy and paste the main thread's stack trace into a reply to the
list; this will tell us exactly what nested call is blocking the loop.

When the code that uses the Scripting Bridge Stops, the thread (main thread in this case) calling the code has the following stack trace (I copied just those after entrance into the method that has the Scripting Bridge calls). My guess is it sent an Apple Event, but it died in the Scripting Bridge for over 2 minutes.


#0	0x9712e7da in mach_msg_trap
#1	0x9712ef47 in mach_msg
#2	0x90507dbf in __CFRunLoopRun
#3	0x90506d34 in CFRunLoopRunSpecific
#4	0x90506b61 in CFRunLoopRunInMode
#5	0x97c086e4 in AESendMessage
#6	0x955c79ba in -[SBAppContext sendEvent:error:]
#7	0x955c1b44 in -[SBObject sendEvent:id:parameters:]
#8	0x955c0b58 in -[SBObject get]
#9	0x955ccc0b in getter_thunk
#10	0x95fecb9f in ffi_closure_SYSV_inner
#11	0x95fec9c2 in ffi_closure_SYSV

Curiously, I paused in debugger and started this email. When I went back and restarted in the debugger, it immediately started up again. Whatever happens in these long pauses was able to complete what it needed to do while my app was paused in debugger.

I tried pausing the target app as well, but could not find evidence of the Scripting Bridge calls (although pausing the target app caused the call ingapp to pause as well, while waiting for replies).

I suggested wrapping your loop with an autorelease pool simply to
remove the potential variable of memory management as being the cause
of the slowdown/pause. The code would look like this with an
autorelease pool present:

for(i=0;i<numRecs;i++)
{
   NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
   id indi=[recs objectAtIndex:i];
   … Do stuff …
   [pool release];
}

It's unlikely that this will have much an effect, but it's worth doing
in our goal to isolate the root cause of the pause/slowdown. (Of
course, the Python equivalent of this code will handle the memory
management for you.)

I tried this autorelease pool and it had no affect on when it paused.

I did notice once that after a long pause, I could run the code again and it would finish without a pause. It always pauses the first time it is run after launching the app, but sometimes finishes without a pause on subsequent runs.

------------
John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

_______________________________________________

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


References: 
 >Scripting Bridge Strange Pauses (From: John Nairn <email@hidden>)
 >Re: Scripting Bridge Strange Pauses (From: Dave Keck <email@hidden>)
 >Re: Scripting Bridge Strange Pauses (From: John Nairn <email@hidden>)
 >Re: Scripting Bridge Strange Pauses (From: Dave Keck <email@hidden>)

  • Prev by Date: Re: bindings and NSNumberFormatter, enforcing min/max values
  • Next by Date: SCPreferencesLock issue?
  • Previous by thread: Re: Scripting Bridge Strange Pauses
  • Next by thread: Re: Scripting Bridge Strange Pauses
  • Index(es):
    • Date
    • Thread