Repair PDFium crashes for old Android versions or include own library

643 views Asked by At

I have an Android app which uses the standard PdfRenderer to render PDFs. It is working so far so good and I managed to get rid of the most of the errors in the app.

The only error I have no idea how to get rid of is:

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7
#00  pc 00000000000be7e0  /system/lib/libpdfium.so (FPDF_CloseDocument+12)

It is happening in several variations (not only FPDF_CloseDocument) and produces up to 4% of crashes in daily sessions. The problem is encountered on Android versions from 5 to 8 on various devices.

After some searching, it appears, that PDFium library (on which PdfRenderer is based on) had some bugs in earlier versions. That's why the problem is not appearing on Android versions 9 and 10.

So my practical task is to get rid of 11 SIGSEGV crashes.

Here I have the following ideas:

  1. Include the latest version of PDFium into my app. Currently libpdfium.so is included to Android OS. Can I include the final corrected library into my app and use it? Where to find the libpdfium.so and how to use it in the app?

  2. Use an alternative PDF renderer. I need to render a part of a PDF page in a desired zoom and resolution and I need a pretty loose license like MIT or Apache, so I don't need to open source of my project. I didn't find any appropriate, e.g. MuPDF requires to open source the whole your project, PSPDFKit is fully proprietary.

What way is better to get rid of 11 SIGSEGV crashes?

1

There are 1 answers

3
Szymon Klimaszewski On BEST ANSWER

Check your threading and make sure there is no concurrency issue, as per doc it's not thread safe: https://developer.android.com/reference/android/graphics/pdf/PdfRenderer