Pdf viewer crashes app on save

The app works perfectly fine on my Samsung and one plus phones, but when I tried on a Samsung tablet I'm facing the following issues:


  • The file takes much longer to load
  • The page is sometimes unresponsive / much slower
  • The app sometimes crashes when saving document
  • Sometimes, instead of crashing it would send me back to the previous screen


Crash Error:

W/ample.diagnosi(23302): 0xebadde09 skipped times: 0

F/libc (23302): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x9c in tid 23499 (pool-8-thread-1), pid 23302 (ample.diagnosis)

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

Build fingerprint: 'Verizon/gtasliteltevzw/gtasliteltevzw:10/QP1A.190711.020/T387VVRU3CUI2:user/release-keys'

Revision: '5'

ABI: 'arm'

Timestamp: 2024-06-24 17:09:37-0400

pid: 23302, tid: 23499, name: pool-8-thread-1 >>> com.example.diagnosis <<<

uid: 10227

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x9c

Cause: null pointer dereference

    r0 00000090 r1 00000000 r2 00000090 r3 00004bdd

    r4 00000090 r5 89b79f70 r6 89b79f60 r7 00000000

    r8 00000000 r9 00000000 r10 00000000 r11 00000000

    ip b20f1078 sp 62f7ae90 lr b1ed0534 pc b1ed11a0

backtrace:

      #00 pc 002861a0 /system/lib/libpdfium.so (CPDF_ColorSpace::CreateBuf()+4) (BuildId: 991b323e24070e905c45c62db0f3c815)

      #01 pc 00285530 /system/lib/libpdfium.so (CPDF_Color::SetColorSpace(CPDF_ColorSpace*)+144) (BuildId: 991b323e24070e905c45c62db0f3c815)

      #02 pc 00289ae0 /system/lib/libpdfium.so (CPDF_ColorState::SetDefault()+164) (BuildId: 991b323e24070e905c45c62db0f3c815)

      #03 pc 002eeea4 /system/lib/libpdfium.so (CPDF_RenderStatus::Initialize(CPDF_RenderContext*, CFX_RenderDevice*, CFX_Matrix const*, CPDF_PageObject const*, CPDF_RenderStatus const*, CPDF_GraphicStates const*, CPDF_RenderOptions const*, int, bool, CPDF_Dictionary*, bool, CPDF_Type3Char*, unsigned int, unsigned int, bool)+480) (BuildId: 991b323e24070e905c45c62db0f3c815)

      #04 pc 002edd80 /system/lib/libpdfium.so (CPDF_ProgressiveRenderer::Continue(IFX_PauseIndicator*)+388) (BuildId: 991b323e24070e905c45c62db0f3c815)

      #05 pc 0025ae90 /system/lib/libpdfium.so ((anonymous namespace)::RenderPageImpl(CPDF_PageRenderContext*, CPDF_Page*, CFX_Matrix const&, FX_RECT const&, int, bool, IFSDK_PAUSE_Adapter*)+580) (BuildId: 991b323e24070e905c45c62db0f3c815)

      #06 pc 0025aafc /system/lib/libpdfium.so (FPDF_RenderPageBitmapWithMatrix+480) (BuildId: 991b323e24070e905c45c62db0f3c815)

      #07 pc 00123a5d /system/lib/libandroid_runtime.so (android::nativeRenderPage(_JNIEnv*, _jclass*, long long, long long, long long, int, int, int, int, long long, int)+236) (BuildId: faf898b6bda84eb8c94acd8a490b47f6)

      #08 pc 002ed2a1 /system/framework/arm/boot-framework.oat (art_jni_trampoline+192) (BuildId: d12e8655e6b3af26862fba2854d4813a2d0ac8ac)

      #09 pc 000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #10 pc 004370c9 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_static_stub+248) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #11 pc 000dffff /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+198) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #12 pc 00213875 /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+280) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #13 pc 0020fe7d /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<true, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+552) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #14 pc 00431025 /apex/com.android.runtime/lib/libart.so (MterpInvokeStaticRange+192) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #15 pc 000d2c94 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static_range+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #16 pc 00429a7c /system/framework/framework.jar (android.graphics.pdf.PdfRenderer.access$400)

      #17 pc 0043120f /apex/com.android.runtime/lib/libart.so (MterpInvokeStaticRange+682) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #18 pc 000d2c94 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_static_range+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #19 pc 004297ac /system/framework/framework.jar (android.graphics.pdf.PdfRenderer$Page.render+444)

      #20 pc 0042c461 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1192) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #21 pc 000d2814 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #22 pc 0002e7dc [anon:dalvik-classes2.dex extracted in memory from /data/app/com.example.diagnosis-uevo4UdYw2Y9zehS4j8S5g==/base.apk!classes2.dex] (com.syncfusion.flutter.pdfviewer.PdfRunnable.run+124)

      #23 pc 0042d967 /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1542) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #24 pc 000d2a14 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #25 pc 001e73bc /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.Executors$RunnableAdapter.call+4)

      #26 pc 0042d967 /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1542) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #27 pc 000d2a14 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #28 pc 001ed3fe /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.FutureTask.run+62)

      #29 pc 0042d967 /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1542) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #30 pc 000d2a14 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #31 pc 001f8446 /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor.runWorker+158)

      #32 pc 0042c461 /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1192) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #33 pc 000d2814 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #34 pc 001f71f4 /apex/com.android.runtime/javalib/core-oj.jar (java.util.concurrent.ThreadPoolExecutor$Worker.run+4)

      #35 pc 0042d967 /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1542) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #36 pc 000d2a14 /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #37 pc 000eaa54 /apex/com.android.runtime/javalib/core-oj.jar (java.lang.Thread.run+8)

      #38 pc 001eeb79 /apex/com.android.runtime/lib/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEbb.llvm.2237354601837329179+192) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #39 pc 001f336b /apex/com.android.runtime/lib/libart.so (art::interpreter::EnterInterpreterFromEntryPoint(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*)+126) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #40 pc 00420a9d /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+852) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #41 pc 000dc5a1 /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #42 pc 000d7bc5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #43 pc 00436fb5 /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+252) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #44 pc 000dffeb /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+178) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #45 pc 00377deb /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #46 pc 00378b73 /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+306) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #47 pc 003aa1bb /apex/com.android.runtime/lib/libart.so (art::Thread::CreateCallback(void*)+982) (BuildId: 16c641c14a01ea3d297b42480c523cef)

      #48 pc 000abcdb /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+20) (BuildId: 8f5d1631f046aa23ddeaa4c33901533c)

      #49 pc 00062d93 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: 8f5d1631f046aa23ddeaa4c33901533c)

Lost connection to device.


Exited.



12 Replies

IP ImmanKumarP Palanikumar Syncfusion Team June 25, 2024 10:39 AM UTC

Hi Ziad Ghanem,


We are unable to replicate the reported issue using the provided stack trace information. Could you please share the following information?


1. Device information - Device model, Android OS version, RAM and internal storage

2. Syncfusion_flutter_pdfviewer package version in which the issue occurs

3. Simple sample / code snippet to replicate the issue

4. Replication procedure / Replication video


This will help us to investigate the issue further and provide you with a prompt solution.


Regards,

Imman Kumar P




ZG Ziad Ghanem June 25, 2024 06:52 PM UTC

  1. Device Information:
    Galaxy Tab A8 (SM-T387V)
    Android 10
    2 GB RAM
    32 GB Storage
  2. Syncfusion_flutter_pdfviewer: 25.2.6
  3. Code Snippet: 
  4. if (documentSaveable) {
                    List<PdfFormField> formFields =
                        _pdfViewerController.getFormFields();

                    final List<PdfFormField> listboxes = formFields
                        .where((PdfFormField formField) =>
                            formField.name.startsWith("listbox_"))
                        .toList();

                    if (listboxes.isEmpty) {
                      final File savedFile = await _saveDocument();
                      if (context.mounted) {
                        Navigator.pop(context, savedFile);
                      }
                    } else {
                      await _checkDocumentOutput(listboxes);
                    }
                  }
    Future<File> _saveDocument() async {
        final patientName =
            "${widget.patient.firstName}_${widget.patient.lastName}";

        List<int> savedBytes = await _pdfViewerController.saveDocument(
            flattenOption: PdfFlattenOption.formFields);
        final directory = await getTemporaryDirectory();
        final savedFile = File('${directory.path}/${widget.pdfName}-$patientName');
        await savedFile.writeAsBytes(savedBytes);
        return savedFile;
      }
  5. Videos Attached

Attachment: vids_e2a3afac.zip


ZG Ziad Ghanem June 25, 2024 08:05 PM UTC

Also is it possible to change the signature field width and height or flip the screen and expand the signature field in the pdf form?



IP ImmanKumarP Palanikumar Syncfusion Team June 26, 2024 02:44 PM UTC

Hi Ziad Ghanem,

Pdf viewer crashes app on save

Still, we are unable to replicate the issue. Can you please create a simple sample with only the save method and check whether the application is crashing in the device?

Also, we suspect that issue might be specific to the document. Please share a simple sample along with document in which the issue occurs to analyze the issue further and provide you with a prompt solution.

Also is it possible to change the signature field width and height or flip the screen and expand the signature field in the pdf form?

At present, SfPdfViewer widget doesn't have the support to change the size of the signature pad dialog.

However, you can display a custom signature pad to sign the Signature field in the PDF document.

Please find the UG link for the same,
https://help.syncfusion.com/document-processing/pdf/pdf-viewer/flutter/form-filling#how-to-create-and-display-a-custom-signature-pad

Regards,

Imman Kumar P



ZG Ziad Ghanem June 26, 2024 07:57 PM UTC

I made another sample of the PDF viewer without any of the extra stuff

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:path_provider/path_provider.dart';
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';

Future<File> getFileFromAssets(String fileName) async {
  final byteData = await rootBundle.load('assets/pdfs/$fileName');
  final file = File('${(await getTemporaryDirectory()).path}/$fileName');
  await file.create(recursive: true);
  await file.writeAsBytes(byteData.buffer
      .asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
  return file;
}

class WidgetTest extends StatefulWidget {
  const WidgetTest({super.key});

  @override
  State<WidgetTest> createState() => _WidgetTestState();
}

class _WidgetTestState extends State<WidgetTest> {
  final _pdfViewerController = PdfViewerController();

  String filename = "Eval.pdf";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        actions: [
          IconButton(
            onPressed: () async {
              List<int> savedBytes = await _pdfViewerController.saveDocument(
                  flattenOption: PdfFlattenOption.formFields);
              final directory = await getTemporaryDirectory();
              final savedFile = File('${directory.path}/test.pdf');
              await savedFile.writeAsBytes(savedBytes);
              setState(() {
                filename = "Eval_output.pdf";
              });
              ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                  content: Text('Document saved to ${savedFile.path}')));
            },
            icon: const Icon(Icons.save),
          )
        ],
      ),
      body: FutureBuilder<File>(
        future: getFileFromAssets(filename),
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.done) {
            if (snapshot.hasData) {
              return SfPdfViewer.file(
                snapshot.data!,
                controller: _pdfViewerController,
              );
            } else {
              return Center(child: Text('Error loading PDF'));
            }
          } else {
            return Center(child: CircularProgressIndicator());
          }
        },
      ),
    );
  }
}


I couldn't get it to crash, but the document response is very slow. To reiterate, the crashes in the main app are not consistent they happen to any of the documents shown in the video and sometimes everything works without crashing. Also this behavior only happens on this device (the tablet), other device work perfectly fine.

I have attached the document with the most form fields, but again the crashing isn't only specific to this document.


Attachment: Eval_71f1027f.zip


IP ImmanKumarP Palanikumar Syncfusion Team June 27, 2024 02:37 PM UTC

Hi Ziad Ghanem,

We are unable to replicate the application crash even with the shared document in a simple sample. Could you please check with your main application and share the complete stack trace with us?

We are able to replicate the issue that "PDFs with many form fields are less responsive." Currently, we are validating this issue and will provide further details by July 1, 2024.

Regards,

Imman Kumar P



ZG Ziad Ghanem June 27, 2024 11:02 PM UTC

I have attached the stack trace. 

The first exception (java.lang.IllegalStateException: Current page not closed) was not fatal at least didn't cause any issues in debug mode.

The second exception (Exception caught by widgets library) caused the application to back track to the previous page.

Last exception at the bottom of the text file caused the crash.


I suspect the reason for the issues is due to the unresponsiveness of the PDFViewer causing various issues with application's system. I can only see the difference being that this device has much less Memory than the other devices I tested.


Attachment: stack_trace_ffba923c.zip


IP ImmanKumarP Palanikumar Syncfusion Team June 28, 2024 10:38 AM UTC

Hi Ziad Ghanem,

Thank you for sharing the stack trace details.

We will analyze the stack trace and provide an update on the validation details by July 1, 2024.

In the meantime, could you please check if you are experiencing the reported issues with the latest version of the syncfusion_flutter_pdfviewer package, version 26.1.39?

Regards,
Imman Kumar P



ZG Ziad Ghanem June 28, 2024 08:35 PM UTC

After updating to version 26.1.39, the crashing stopped. I believe that's because this version is more optimized?  However, I'll be doing further testing since the crashing apparently happens due to insufficient memory (maybe put more strain on the device). 


The other issue remains: The PDF Viewer is very slow especially in PDFs with many form fields. Awaiting your reply on July 1




DG Deepak Gunasekaran Syncfusion Team July 1, 2024 02:45 PM UTC

Hi Ziad,


Sorry for the inconvenience caused. Due to complexity, we are still validating the performance issue in the form filling document scrolling. We are checking on this with high priority and will update further details on 3rd July, 2024.


Regards,

Deepak G



IP ImmanKumarP Palanikumar Syncfusion Team July 3, 2024 02:55 PM UTC

Hi Ziad Ghanem,

In the SfPdfViewer widget, we are adding pages on demand to reduce memory consumption. While loading a page, we render the form fields for that page. Due to the large number of widgets that need to be created on demand and the inability to move widget creation to a separate thread, there is a significant performance impact in SfPdfViewer.

Although the performance issue cannot be completely addressed, we plan to improve the performance of form field rendering as much as possible, and the enhancement will be included in the weekly release on July 16, 2024.

Please use the feedback link to track the status of the bug, Scrolling performance degradation in SfPdfViewer with documents containing a large number of form fields in Flutter | Feedback Portal (syncfusion.com)

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”

Regards,

Imman Kumar P



IP ImmanKumarP Palanikumar Syncfusion Team July 16, 2024 12:57 PM UTC

Hi Ziad Ghanem,

We have improved the performance of the SfPdfViewer widget when loading PDF documents with a large number of form fields as much as possible, and this is available in our latest weekly release.

Package link: syncfusion_flutter_pdfviewer v26.1.42

We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

Regards,

Imman Kumar P


Loader.
Up arrow icon