nsimage, nsthread, nsattributedstring problems
nsimage, nsthread, nsattributedstring problems
- Subject: nsimage, nsthread, nsattributedstring problems
- From: "Jeff Evans" <email@hidden>
- Date: Sat, 24 Aug 2002 18:24:42 -0500
Hello list,
I've got a cocoa app that loads bundles which create nsviews that attach to
the main app's window. these plugin bundles set up timers and do some
drawing and sql stuff using a framework i put together. At first, each
plugin spawned its own thread including its drawRect function, but i got
into lots of nsViewHierarchyLock problems, so I went to timers, and those
problems went away. Now, the only threads I create is in one plugin which
spawns an addcontent function. this gets some data from a subplugin, and
sends that data so some other plugins which return an nsview and an
nsimageview. these two views create NSImages and draw to them in the init
function; the NSView subclass(DefaultContent) calls compositeToPoint in
drawRect and the nsImageView subclass(DescriptionView) calls [super
drawRect] in its drawRect. Everything works fine, but after about 6 hours,
my program gets signalled while in a function called by GDB. There are
three threads running, though the numbers aren't always the same. Thread
one always has LOTS of frames (this current example has 2230) frames, while
the other two threads have far fewer but still alot. Here's what I mean.
Thread 1:
01-free_list_add_prt
02-malloc_zone_calloc
03-_internal_class_createInstanceFromZone
04-NSAllocateObject
05-+[NSObject allocWithZone:]
06-+[NSSimpleHorizonalTypesetter new]
07--[NSSimpleHorizontalTypesetter
layoutGLyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:ne
xtGlyphIndex:]
08--[NSLayoutManager(NSPrivate)
_fillLayoutHoleAtIndex:desiredNumberOfLines:]
09-_NSFastFillAllLayoutHolesUpToGlyphIndex
10-[NSLayoutManager textContainerForGlyphAtIndex:effectiveRange:]
11--[NSSimpleHorizontalTypesetter
layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragments:ne
xtGlyphIndex:]
then lines 7 through 11 repeat about 500 times and then...
2204-[NSStringDrawingTextStorage drawTextContainer:inRect:onView:pinToTop:]
2205-[NSAttributeString(NSStringDrawing)drawInRect:]
2206-[NSString(NSStringDrawing)drawInRect:withAttributes:]
2207-[ScrollView drawRect]
2208-[NSView _drawRect:clip]
2209-[NSView
_recursiveDisplayRectIfNeededIgnoringCapacity:isVisibleRect:rectIsVisibleRec
tForView:topView]
2210-[NSView
_recursiveDisplayRectIfNeededIgnoringCapacity:isVisibleRect:rectIsVisibleRec
tForView:topView]
2211-[NSView
_recursiveDisplayRectIfNeededIgnoringCapacity:isVisibleRect:rectIsVisibleRec
tForView:topView]
2212-[NSFrameView
_recursiveDisplayRectIfNeededIgnoringOpactiy:isVisibleRect:rectIsVisibleRect
ForView:topView]
2213-[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRect
ForView:topView]
2214-[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
2215-[NSView displayIfNeeded]
2216-[NSWindow displayIfNeeded]
2217-_handleWindowNeedsDisplay
2218-CFRunLoopRunInMode
2219-CFRunLoopRunInMode
2220-CFRunLoopRunSpecific
2221-CFRunLoopRunInMode
2222-InvokeThemeButtonDrawUPP
2223-GetNextWindow
2224-BlockUntilNextEventMatchingListInMode
2225-_DPSNextEvent
2226--[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
2227--[NSApplication run]
2228-NSApplicationMain
2229-_start
2230-start
Thread 4:
0 mach_msg_overwrite_trap
1 mach_msg
2 _pthread_become_available
3 pthread_exit
4 -[NSThread _exit]
5 forkThreadForFunction
6 _pthread_body
Thread 5:
00 dyld_stub__spin_lock_try
01 szone_free
02 malloc_zone_free
03 free
04 CGClipRelease
05 CGContextClipToRect
06 NSRectClip
07 -[NSFocusState flush]
08 -[NSView _focusFromView:withThread:]
09 -[NSView lockFocusIfCanDraw]
10 -[NSView lockFocus]
11 -[NSStringDrawingTextStorage drawTextContainer:inRect:onView:pinToTop:]
12 -[NSAttributeString(NSStringDrawing)drawInRect:]
13 -[NSString(NSStringDrawing) drawInRect:withAttributes:]
14 -[DefaultContent drawShow:inRect]
15 -[DefaultContent drawChannelAndInfo:inRect:]
16 -[DefaultContent makeImage]
17 -[DefaultContent initWithFrame:withContent:withInfo:]
18 -[DisplayPlugin contentWithFrame:withContent:withInfo:]
19 -[DisplayPlugin contentWithFrame:wihtContent:withInfo:]
20 -[ScrollView addContent:]
21 forkThreadForFunction
22 _pthread_body
GDB is dead so i had to type that all by hand...i hope there aren't too many
typos. Basically, what would call that huge recursive mess in thread 1?
does it have anything to do with thread 5? I tried to write my code so
there wouldn't be any more than two threads in my app at a time, so how did
the thread number get to 5 and why hasn't 4 gone away yet? Thanks for
reading this far...please please help me or let me know what other info you
need from me. The problem seems to have to do with multiple threads calling
[NSString drawInRect] at the same time. Is this an example of how unthread
safe the AppKit is? How would you recommend I fix things if this is the
case? Convert everything to NSImages so I can cache things and only call
drawInRect once?
Many thanks in advance...have a great Sunday.
-Jeff
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.