I have a quiet long program so I want to display some progress information about what is happening.
So I start the long treatment using
performSelectorInBackground_withObject_("bench", missing value)
Almost when entering in ‘bench’ I post message to the main thread for logging.
set userMSG to (current date) as text
if writeTestCheck's objectValue() then
set userMSG to userMSG & " : Write Test: "
else
set userMSG to userMSG & " : Read test: "
end if
log "in bench() will call performSelectorOnMainThread"
performSelectorOnMainThread_withObject_waitUntilDone_("logToMyScrollView:", userMSG, true)
logToMyScrollView is wrting the text in input at the end of my scroll view.
on logToMyScrollView_(aMessage)
myScrollView's documentView()'s textStorage()'s mutableString()'s appendString_((aMessage as text) & return)
--scroll to the end of range
set newTextLength to myScrollView's documentView()'s textStorage()'s mutableString()'s |length|() as integer
myScrollView's documentView()'s scrollRangeToVisible_({|location|:newTextLength, |length|:0})
end logToMyScrollView_
The freeze is random, however it always happen the 1st time I call performSelectorOnMainThread_withObject_waitUntilDone_(“logToMyScrollView:”, userMSG, true) in the background thread.
If this call works, all the subsequent calls works fine.
I know from the log I put that when freezing the program reach this point and I can see that my log message are not happening.
If I sample the process here is what I’m getting.
As any one an idea of what I’m doing wrong there ?
Sampling process 2417 for 3 seconds with 1 millisecond of run time between samples
Sampling completed, processing symbols…
Analysis of sampling MassStorageBench (pid 2417) every 1 millisecond
Process: MassStorageBench [2417]
Path: /Users/r42555/Documents/DevProjects/MassStorageBench/build/Release/MassStorageBench.app/Contents/MacOS/MassStorageBench
Load Address: 0x100000000
Identifier: com.yourcompany.MassStorageBench
Version: 1.0 (1.0)
Code Type: X86-64 (Native)
Parent Process: launchd [213]
Date/Time: 2011-02-01 11:05:22.061 +0100
OS Version: Mac OS X 10.6.6 (10J567)
Report Version: 6
Call graph:
2480 Thread_36512 DispatchQueue_1: com.apple.main-thread (serial)
2480 start
2480 NSApplicationMain
2480 -[NSApplication run]
2480 -[NSApplication sendEvent:]
2480 -[NSWindow sendEvent:]
2480 -[NSControl mouseDown:]
2480 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:]
2480 -[NSCell trackMouse:inRect:ofView:untilMouseUp:]
2480 -[NSControl sendAction:to:]
2480 -[NSApplication sendAction:to:from:]
2480 _CF_forwarding_prep_0
2480 forwarding
2480 -[BAObjectProto forwardInvocation:]
2480 -[BAObjectProto invokeScriptHandler:args:error:]
2480 +[BAObjectProto invokeScriptHandler:forObject:args:error:]
2480 OSAExecuteEvent
2480 AppleScriptComponent
2480 CallComponentFunction
2480 ASExecuteEvent(AEDesc const*, unsigned int, int, unsigned int*)
2480 UASExecute1()
2480 UASActor_Send(unsigned char, unsigned char, unsigned char)
2480 UASRemoteSend(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char*)
2480 TUASApplication::Send(TStackFrame_UASRemoteSend*, AEDesc*, AEDesc*, unsigned char, unsigned char, unsigned char)
2480 ComponentSend(AEDesc const*, AEDesc*, int, int)
2480 AppleScriptUnlocker::~AppleScriptUnlocker()
2480 _pthread_cond_wait
2480 __semwait_signal
2480 Thread_36529 DispatchQueue_2: com.apple.libdispatch-manager (serial)
2480 start_wqthread
2480 _pthread_wqthread
2480 _dispatch_worker_thread2
2480 _dispatch_queue_invoke
2480 _dispatch_mgr_invoke
2480 kevent
2480 Thread_36552
2480 thread_start
2480 _pthread_start
2480 PrivateMPEntryPoint
2480 TSystemNotificationTask::SystemNotificationTaskProc(void*)
2480 CFRunLoopRun
2480 CFRunLoopRunSpecific
2480 __CFRunLoopRun
2480 mach_msg
2480 mach_msg_trap
2480 Thread_36560: com.apple.CFSocket.private
2480 thread_start
2480 _pthread_start
2480 __CFSocketManager
2480 select$DARWIN_EXTSN
2480 Thread_36561
2480 thread_start
2480 _pthread_start
2480 NSThread__main
2480 -[NSUIHeartBeat _heartBeatThread:]
2479 usleep
2469 nanosleep
2469 __semwait_signal
10 cerror
9 cerror
1 cthread_set_errno_self
1 -[NSApplication _keyWindowForHeartBeat]
1 objc_msgSend
2480 Thread_36578
2480 thread_start
2480 _pthread_start
2480 NSThread__main
2480 CF_forwarding_prep_0
2480 forwarding
2480 -[BAObjectProto forwardInvocation:]
2480 -[BAObjectProto invokeScriptHandler:args:error:]
2480 +[BAObjectProto invokeScriptHandler:forObject:args:error:]
2480 OSAExecuteEvent
2480 AppleScriptComponent
2480 CallComponentFunction
2480 ASExecuteEvent(AEDesc const*, unsigned int, int, unsigned int*)
2480 UASExecute1()
2480 UASActor_Send(unsigned char, unsigned char, unsigned char)
2480 UASRemoteSend(unsigned char, unsigned char, unsigned char, unsigned char, unsigned char, unsigned char*)
2480 TUASApplication::Send(TStackFrame_UASRemoteSend*, AEDesc*, AEDesc*, unsigned char, unsigned char, unsigned char)
2480 ComponentSend(AEDesc const*, AEDesc*, int, int)
2480 BASendProc
2480 InvokeHandler
2480 -[NSInvocation invoke]
2480 invoking
2480 -[NSObject(NSThreadPerformAdditions) performSelectorOnMainThread:withObject:waitUntilDone:]
2480 -[NSObject(NSThreadPerformAdditions) performSelector:onThread:withObject:waitUntilDone:modes:]
2480 -[NSCondition wait]
2480 _pthread_cond_wait
2480 __semwait_signal
1151 Thread_38445
1151 start_wqthread
1151 _pthread_wqthread
1151 __workq_kernreturn
1151 Thread_38446
1151 start_wqthread
1151 _pthread_wqthread
1151 __workq_kernreturn
1 Thread_38445 DispatchQueue_34: TFSVolumeInfo::GetSizingGCDQueue (serial)
1 start_wqthread
1 _pthread_wqthread
1 _dispatch_worker_thread2
1 _dispatch_queue_invoke
1 _dispatch_queue_drain
1 _dispatch_queue_invoke
1 _dispatch_source_invoke
1 __dispatch_source_mig_create_block_invoke_1
1 dispatch_mig_server
1 dispatch_rcv_msg
1 FSEventsD2F_server
1 _Xcallback_rpc
1 implementation_callback_rpc
1 malloc
1 malloc_zone_malloc
1 szone_malloc_should_clear
1 tiny_malloc_from_free_list
Total number in stack (recursive counted multiple, when >=5):
Sort by top of stack, same collapsed (when >= 5):
__semwait_signal 7429
kevent 2480
mach_msg_trap 2480
select$DARWIN_EXTSN 2480
__workq_kernreturn 2302
cerror 9