On 19 Sep 2009, at 00:36, Raleigh Ledet wrote:

You are printing the same instance of a view that is in your UI. So basically, your are trying to get the same view to print on two threads. Unless your view can handle concurrent drawing, this could be bad. NSTextView doesn't support concurrent drawing. I think you were getting lucky on Leopard.
And lucky on Tiger too.

Possible solutions:
1. Don't print concurrently.
That is my current solution. It blocks the user interface, which is bad, but 1000 pages get printed in well under 20 seconds, so it's not too bad.

2. Create another view and set it up with the content from your UI. Use this view for printing on a background thread.
Thanks for this suggestion. I will try it, when the blocking becomes annoying.


-raleigh

On Sep 12, 2009, at 6:18 AM, Gerriet M. Denkmann wrote:


On 11 Sep 2009, at 21:28, Corbin Dunn wrote:

Hi Gerriet,
Have you tried running with Zombies?
Yes.

Run -> Run With Performance Tool -> Zombies

If so, does that show an overrelease anywhere?
No.

Can you please log a bug on bugreporter.apple.com if you believe it is a bug in the Apple framework. Please include an isolated test case, if possible (that will greatly speed up investigation into the issue, especially if it is a recent regression).
Bug ID# 7218833.

thanks,

corbin

On Sep 10, 2009, at 10:54 PM, Gerriet M. Denkmann wrote:

An app which ran without problems on Leopard likes to crash on Snow Leopard (10.6.1) (both in i386 and x86_64).

How to crash: print several times; might crash the first time, might crash the seventh time, but crash it will.

The backtrace and the location of the crash varies wildly. In almost always it is some NSFont method. The backtrace below is an exception. But still related to layout stuff.

I have a very strong feeling, that something (my code? Apple's printing code?) corrupts some memory which then results in random errors. Or maybe not: just ran it a dozen times with GuardMalloc and it refused to crash. And GuardMalloc did not report any problems.
So maybe it is some timing problem with multiple threads?
I tried it more than a dozen times with: setCanSpawnSeparateThread: NO and it did not crash.

Are there any known problems with printing using setCanSpawnSeparateThread: YES?



====== the code ========

- (IBAction)printIt: sender ;
{
        (void)sender;
        
        ... get path from NSSavePanel ....
        NSLog(@"%s got path \"%...@\"",__FUNCTION__, path);
        
        NSPrintInfo *printInfo = [ self printInfo ];

        [ printInfo setJobDisposition: NSPrintSaveJob ];
        NSMutableDictionary *dictionary = [ printInfo dictionary ];
        [ dictionary setObject: path  forKey: NSPrintSavePath ];
[ dictionary setObject: [ NSNumber numberWithBool: YES ] forKey: NSPrintAllPages ];
        NSLog(@"%s dictionary %@",__FUNCTION__, dictionary);
        
NSPrintOperation *po = [ NSPrintOperation printOperationWithView: textView printInfo: printInfo ];
        [ po setShowsPrintPanel: NO ];
        [ po setCanSpawnSeparateThread: YES ];

        NSLog(@"%s NSPrintOperation %@",__FUNCTION__, po);
NSLog(@"%s will runOperationModalForWindow for %@",__FUNCTION__, [ textView window ]);
        [ po    runOperationModalForWindow: [ textView window ]
                        delegate:                                       self
didRunSelector: @selector ( printOperationDidRun:success:contextInfo: )
                        contextInfo:                            NULL
        ];

        NSLog(@"%s printing \"%...@\"",__FUNCTION__, path);
}


- (void)printOperationDidRun:(NSPrintOperation *)printOperation success:(BOOL)ok contextInfo:(void *)contextInfo
{
        if ( !ok )      //      error
        {
NSLog(@"%s Error in: runOperationModalForWindow:delegate:didRunSelector:contextInfo :",__FUNCTION__);
                return;
        };
        
        NSPrintInfo *printInfo = [ printOperation printInfo ];
        NSMutableDictionary *dictionary = [ printInfo dictionary ];
        NSString *path = [ dictionary objectForKey: NSPrintSavePath ];

        NSLog(@"%s printed \"%...@\"",__FUNCTION__, path);
        NSLog(@"%s printInfo %@",__FUNCTION__, printInfo);
        
        return; 
}

====== the output ========

-[GymDocument printIt:] got path "/private/var/folders/+s/ +sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading 1...4.pdf"
-[GymDocument printIt:] dictionary {
NSBottomMargin = 41;
NSCopies = 1;
NSDetailedErrorReporting = 0;
NSFaxNumber = "";
NSFirstPage = 1;
NSHorizonalPagination = 2;
NSHorizontallyCentered = 1;
NSJobDisposition = NSPrintSaveJob;
NSJobSavingFileNameExtensionHidden = 0;
NSJobSavingURL = "file://localhost/var/folders/+s/+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading%201...4.pdf ";
NSLastPage = 2147483647;
NSLeftMargin = 18;
NSMustCollate = 1;
NSOrientation = 0;
NSPagesAcross = 1;
NSPagesDown = 1;
NSPaperName = "iso-a4";
NSPaperSize = "NSSize: {595, 842}";
NSPrintAllPages = 1;
NSPrintProtected = 0;
NSPrintTime = "0001-01-01 06:42:04 +064204";
NSPrinter = "{\n \"Device Description\" = {\n NSDeviceIsPrinter = YES;\n };\n \"Language Level\" = 2;\n Name = \" \";\n Type = \"\";\n}";
NSPrinterName = " ";
NSRightMargin = 18;
NSSavePath = "/var/folders/+s/+sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/ Reading 1...4.pdf";
NSScalingFactor = 1;
NSTopMargin = 18;
NSVerticalPagination = 0;
NSVerticallyCentered = 1;
}
-[GymDocument printIt:] NSPrintOperation <NSConcretePrintOperation: 0x1158392e0> -[GymDocument printIt:] will runOperationModalForWindow for <NSWindow: 0x100191b40> -[GymDocument printIt:] printing "/private/var/folders/+s/ +sLxz7jCEUSrZ3BtxGVGUU+++TM/-Tmp-/Reading 1...4.pdf"
Program received signal:  “EXC_BAD_ACCESS”.
(gdb) bt
#0  0x00007fff82b5843e in blockForLocation ()
#1 0x00007fff82b59c80 in -[NSRLEArray objectAtIndex:effectiveRange:] () #2 0x00007fff82b5fb25 in -[NSConcreteMutableAttributedString attribute:atIndex:effectiveRange:] () #3 0x00007fff83caa931 in -[NSConcreteTextStorage attribute:atIndex:effectiveRange:] () #4 0x00007fff83cb813c in -[NSLayoutManager locationForGlyphAtIndex:] () #5 0x00007fff83cb6272 in -[NSLayoutManager(NSPrivate) _drawGlyphsForGlyphRange:atPoint:parameters:] ()
#6  0x00007fff83c7b1a4 in -[NSTextView drawRect:] ()
#7  0x00007fff83c7a836 in -[NSTextView _drawRect:clip:] ()
#8 0x00007fff83c00c10 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView :] () #9 0x00007fff83c0159b in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView :] () #10 0x00007fff83c0159b in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView :] () #11 0x00007fff83c0159b in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView :] () #12 0x00007fff83c0159b in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView :] () #13 0x00007fff83c001f3 in -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView :] () #14 0x00007fff83bfca97 in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView :] ()
#15 0x00007fff83b76237 in -[NSView displayIfNeeded] ()
#16 0x00007fff83b710e3 in _handleWindowNeedsDisplay ()
#17 0x00007fff84a2f437 in __CFRunLoopDoObservers ()
#18 0x00007fff84a0b6e4 in __CFRunLoopRun ()
#19 0x00007fff84a0b03f in CFRunLoopRunSpecific ()
#20 0x00007fff82552c4e in RunCurrentEventLoopInMode ()
#21 0x00007fff825529b1 in ReceiveNextEventCommon ()
#22 0x00007fff8255290c in BlockUntilNextEventMatchingListInMode ()
#23 0x00007fff83b46520 in _DPSNextEvent ()
#24 0x00007fff83b45e89 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#25 0x00007fff83b0ba7d in -[NSApplication run] ()
#26 0x00007fff83b04798 in NSApplicationMain ()
#27 0x0000000100001341 in main (argc=1, argv=0x7fff5fbff5b8) at / Volumes/เม่น/Users/gerriet/Source/Stuff 10.4.8/Gymnure/ main.m:13


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/ledet%40apple.com

This email sent to le...@apple.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to