macOS Tahoe WKWebView - NSPrintOperation EXC_BREAKPOINT with Lots of Error Logging

Running print operation on WKWebView I hit EXC_BREAKPOINT and there is all kinds of console spew that looks concerning:

ERROR: The NSPrintOperation view's frame was not initialized properly before knowsPageRange: returned. (WKPrintingView)

** CGContextClipToRect: invalid context 0x0. If you want to see the backtrace, please set CG_CONTEXT_SHOW_BACKTRACE environmental variable.**

WebContent[7743] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.

CRASHSTRING: XPC_ERROR_CONNECTION_INVALID from launchservicesd

CRASHSTRING: <rdar://problem/28724618> Process unable to create connection because the sandbox denied the right to lookup com.apple.coreservices.launchservicesd and so this process cannot talk to launchservicesd.

WebContent[7921] The sandbox in this process does not allow access to RunningBoard.

Safe to ignore all this?

Hello,

Can you please provide the code in which you created and configured the NSPrintOperation?

Thank you for your patience,

Richard Yeh  Developer Technical Support

Thanks for replying. Sure.

 NSPrintOperation *printOp = [self.webView printOperationWithPrintInfo:[NSPrintInfo sharedPrintInfo]];
if (printOp == nil) 
{
 os_log_fault(OS_LOG_DEFAULT, "Nil print operation."); 
 return; 
}

if (self.view.window != nil)
{
   [printOp runOperationModalForWindow:self.view.window
                                           delegate:self
                                     didRunSelector:@selector(myPrintOperationDidRun:success:contextInfo:)
                                        contextInfo:nil];
}

Hi Macho Man Randy Savage,

Can you please try setting the NSPrintOperation's frame directly like so:

printOp.view.frame = self.webView.bounds

Thank you for your patience,

Richard Yeh  Developer Technical Support

Yes if I set the frame on printOp.view the EXC_BREAKPOINT issue is avoided.

Otherwise the private WKPrintingView configured for the printOp has a frame of NSZeroRect.

macOS Tahoe WKWebView - NSPrintOperation EXC_BREAKPOINT with Lots of Error Logging
 
 
Q