We are generating pdf report in our application using wk-webview. However, app is getting crashed while while we try to draw an image using the UIImage.draw function. We are seeing this crash frequently. iOS version being used is 16.4 and XCode version is 14.3.1. Please find the back trace logs below:
thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
frame #0: 0x000000011599825f CoreGraphicsCGBlitInternal::cgsBufferIsConstantValue_internal::TestLimits<unsigned char, 64ul>::operator()(unsigned char const*, unsigned long, CGBlitInternal::cgsBufferIsConstantValue_internal::Limits const&) + 17 frame #1: 0x0000000115cd4921 CoreGraphics
bool CGBlitInternal::cgsBufferIsConstantValue_internal::TestLimitsRow<unsigned char>(void const*, unsigned long, CGBlitInternal::cgsBufferIsConstantValue_internal::Limits const&) (.10518) + 26
frame #2: 0x0000000115cd469d CoreGraphicsbool CGBlitInternal::CGBufIsConstantValue<(CGBlitVariant)0>(CGBuf const*, float const*, float const*) + 579 frame #3: 0x0000000115cf2fe4 CoreGraphics
is_image_alpha_opaque + 354
frame #4: 0x0000000115d08572 CoreGraphicspdf_DrawImage + 2047 frame #5: 0x0000000115c1e2b8 CoreGraphics
CGContextDrawImageWithOptions + 1232
frame #6: 0x000000012731b11e UIKitCore`-[UIImage drawInRect:blendMode:alpha:] + 1638
frame #7: 0x00000001045e2dc5 ProjectName`CustomPrintPageRenderer.drawImage(image=0x0000600002788630, imageRect=(origin = (x = 537.20000000000005, y = 10), size = (width = 52.68, height = 20)), self=0x00007fe127f8caf0) at CustomPrintPageRenderer.swift:364:15
frame #8: 0x00000001045de6bd ProjectName`CustomPrintPageRenderer.drawHeaderForPage(pageIndex=0, headerRect=(origin = (x = 0, y = 0), size = (width = 595.20000000000005, height = 76)), self=0x00007fe127f8caf0) at CustomPrintPageRenderer.swift:203:9
frame #9: 0x00000001045e0306 ProjectName`@objc CustomPrintPageRenderer.drawHeaderForPage(at:in:) at <compiler-generated>:0
frame #10: 0x000000011a98c9cf PrintKitUI`-[UIPrintPageRenderer drawPageAtIndex:inRect:] + 308
frame #11: 0x0000000104a79943 ProjectName`ReportGenerationService.drawPDF(pageRenderer=0x00007fe127f8caf0, landscape=false, self=0x00006000020c4900) at ReportGenerationService.swift:199:26
- frame #12: 0x0000000104a755b9 ProjectName
closure #2 in ReportGenerationService.renderTemplate(reportSegmentRenderer=0x00007fe127f8caf0, currentPage=0, totalNoOfPages=1, self=0x00006000020c4900, mergePDFData=0 values) at ReportGenerationService.swift:124:46 frame #13: 0x0000000104a7b1ac ProjectName
partial apply for closure #2 in ReportGenerationService.renderTemplate(with:for:reportType:variation:) at <compiler-generated>:0 frame #14: 0x00000001198cd674 libswiftCore.dylibSwift.Sequence.forEach((τ_0_0.Element) throws -> ()) throws -> () + 420 frame #15: 0x0000000104a7488a ProjectName
ReportGenerationService.renderTemplate(reportData=72 key/value pairs, content="{"template": "<html xmlns='http://www.w3.org/1999/xhtml'><head> <title></title> <style> * { font-family: Lato; font-size: 8px; line-height: 12px; } .tblspsbtm { width: 99%; border-bottom: 0.5px solid #636363; } .vitalstitlesloop { font-family: Lato-Regular; font-size: 7pt; } .marginleft { margin-left: 3px; } .table-header-rotated td { width: 30px; border-right: 0.5px solid #636363; vertical-align: middle; text-align: center; word-break: break-word; font-family: Lato-Regular; font-size: 7pt; border-bottom: 0.5px solid #636363; } .table-header-rotated th.rotate-45 { height: 86px; position: relative; vertical-align: bottom; padding: 0; font-family: Lato-Regular; font-size: 7pt; line-height: 0.8; white-space: nowrap; font-weight: normal; } .table-header-rotated th.rotate-45>div { position: relative; top: 0px; left: 43px; height: 100% !important; -ms-transform: skew(-45deg, 0deg); -moz-transform: skew(-45deg, 0deg); -webkit-transform: skew(-45deg, 0deg); -o-transform: skew(-45deg, 0deg); transform: skew(-45deg, ", reportType="Billing Report", variation=nil, self=0x00006000020c4900) at ReportGenerationService.swift:120:32 frame #16: 0x0000000104a7ae01 ProjectNameprotocol witness for ReportGenerationInvokable.renderTemplate(with:for:reportType:variation:) in conformance ReportGenerationService at <compiler-generated>:0 frame #17: 0x0000000104bc22a0 ProjectName
TreatmentReportViewModel.fetchTemplatesfromRealm(data=57 key/value pairs, reportType="Billing Report", variation=nil, self=0x00007fe128be92d0) at TreatmentReportViewModel.swift:395:27 frame #18: 0x0000000104bc0e5f ProjectNameclosure #1 in TreatmentReportViewModel.fetchReportsData(self=0x00007fe128be92d0, data=57 key/value pairs) at TreatmentReportViewModel.swift:379:18 frame #19: 0x000000010452cf98 ProjectName
thunk for @escaping @callee_guaranteed () -> () at <compiler-generated>:0 frame #20: 0x0000000117f0354f libdispatch.dylib_dispatch_call_block_and_release + 12 frame #21: 0x0000000117f047ec libdispatch.dylib
_dispatch_client_callout + 8 frame #22: 0x0000000117f156e2 libdispatch.dylib_dispatch_main_queue_drain + 1462 frame #23: 0x0000000117f1511e libdispatch.dylib
_dispatch_main_queue_callback_4CF + 31 frame #24: 0x0000000116e456cc CoreFoundation__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9 frame #25: 0x0000000116e3ffbe CoreFoundation
__CFRunLoopRun + 2429 frame #26: 0x0000000116e3f264 CoreFoundationCFRunLoopRunSpecific + 560 frame #27: 0x000000011ac7524e GraphicsServices
GSEventRunModal + 139 frame #28: 0x00000001278937bf UIKitCore-[UIApplication _run] + 994 frame #29: 0x00000001278985de UIKitCore
UIApplicationMain + 123 frame #30: 0x0000000104c2e695 ProjectNamemain at main.swift:8:5 frame #31: 0x00000001149a2384 dyld_sim
start_sim + 10 frame #32: 0x000000020c41041f dyld`start + 1903