Crash Report – TRN_UndoManagerDestroy (PDFTron

Product:
PDFTron - iOS Librabry (SPM)

Product Version:
11.3.85075

Hi PDFTron Team,

I recently encountered a crash while using the PDFTron library in an iOS application. The crash happens when the PDF starts loading:

open class PDFDocumentController: PTDocumentController {
    private var didCacheDocumentAtURL: GenericCompletion<URL>?

    public override init() {
        super.init()
    }

    required public init(coder: NSCoder) {
        super.init(coder: coder)
    }

    open override func shouldDeleteCachedDocument(at cachedDocumentURL: URL) -> Bool {
        didCacheDocumentAtURL?(.success(cachedDocumentURL))
        return super.shouldDeleteCachedDocument(at: cachedDocumentURL)
    }

    public func showAnnotations(_ annotationsXFDF: [String]) {
        annotationsXFDF.forEach {
            let fdfDoc = PTFDFDoc.create(fromXFDF: $0)
            document?.fdfMerge(fdfDoc)
        }
        pdfViewCtrl.update()
    }

    private func loadDocument(url: URL,
                              authToken: String,
                              onDidCacheDocumentAtURL: GenericCompletion<URL>? = nil) {
        didCacheDocumentAtURL = onDidCacheDocumentAtURL
        additionalHTTPHeaders = ["Authorization": "Bearer \(authToken)"]
        let options = PTDocumentOptions()
        options.sourcePathExtension = "pdf"
        openDocument(with: url, options: options)
    }

    public func loadDocument(diskURL: URL?,
                             remoteURL: URL,
                             authToken: String,
                             onDidCacheDocumentAtURL: GenericCompletion<URL>? = nil) {
        if let diskURL {
            loadDocument(url: diskURL, authToken: authToken)
        } else {
            loadDocument(url: remoteURL, authToken: authToken, onDidCacheDocumentAtURL: onDidCacheDocumentAtURL)
        }
    }
}

The crash occurred with the following stack trace:

Stack trace:

(lldb) bt  
* thread #962, stop reason = signal SIGABRT  
  * frame #0: 0x00000001e78702ec libsystem_kernel.dylib`__pthread_kill + 8  
    frame #1: 0x00000001fb64cc0c libsystem_pthread.dylib`pthread_kill + 268  
    frame #2: 0x00000001a6bcfba0 libsystem_c.dylib`abort + 180  
    frame #3: 0x00000001fb569ca4 libc++abi.dylib`abort_message + 132  
    frame #4: 0x00000001fb559e5c libc++abi.dylib`demangling_terminate_handler() + 348  
    frame #5: 0x0000000196b8b14c libobjc.A.dylib`_objc_terminate() + 144  
    frame #6: 0x00000001fb569068 libc++abi.dylib`std::__terminate(void (*)()) + 16  
    frame #7: 0x00000001fb56c35c libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 88  
    frame #8: 0x00000001fb56c2a0 libc++abi.dylib`__cxa_throw + 308  
    frame #9: 0x0000000196b6f420 libobjc.A.dylib`objc_exception_throw + 420  
    frame #10: 0x000000019dad49bc Foundation`NSAllocateMemoryPages + 184  
    frame #11: 0x000000019dad1b80 Foundation`-[_NSPlaceholderData initWithBytes:length:copy:deallocator:] + 132  
    frame #12: 0x000000019dad18e8 Foundation`+[NSData(NSData) dataWithBytes:length:] + 40  
    frame #13: 0x0000000103e073dc PDFNet`___lldb_unnamed_symbol11713 + 144  
    frame #14: 0x000000010419d948 PDFNet`___lldb_unnamed_symbol21818 + 100  
    frame #15: 0x000000010419c860 PDFNet`___lldb_unnamed_symbol21808 + 244  
    frame #16: 0x000000010419a8c0 PDFNet`___lldb_unnamed_symbol21784 + 112  
    frame #17: 0x000000010423c50c PDFNet`___lldb_unnamed_symbol23812 + 492  
    frame #18: 0x000000010423b3cc PDFNet`___lldb_unnamed_symbol23799 + 656  
    frame #19: 0x0000000104497048 PDFNet`___lldb_unnamed_symbol34621 + 140  
    frame #20: 0x00000001fb64b06c libsystem_pthread.dylib`_pthread_start + 136  

The other error was also reported in Sentry with the identifier: TRN_UndoManagerDestroy. Not sure if it’s connected, but also has to be fixed. (Please see attached image):

Could you please provide insight into what might be causing this issue or suggest any possible workarounds? Let me know if you need any additional information.

Best regards

1 Like

Thank you for reaching out to us through our Forum. In order to further assist you, we will need you to reproduce this issue and provide a video and sample of the issue you are encountering. You can submit a support ticket with all necessary materials here: Submit a ticket : Apryse

1 Like