2

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?

mspnr
  • 416
  • 4
  • 12
  • Do you compile your project on Android 4.1? I started to observe this issue on apps built with latest tools. – Szymon Klimaszewski Oct 30 '20 at 09:55
  • I use Android Studio 4.2 Canary. I tend to think it is Android OS version of the devices. Unfortunately I can't reliably reproduce the issue in my own environment, and only see it in Google Play crashes. So I can't research the issue properly. – mspnr Oct 30 '20 at 10:43

1 Answers1

2

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

  • This is a very good point. Actually PdfRenderer is created in several activities for different purposes: to display pages or thumbnails etc. So create-open-close in every single activity is synchronized, but not between activities. I would create a static variable / class for on the application level and would call its open-close from different activities. What do you think about this approach? Real practical test will take some time. – mspnr Nov 04 '20 at 14:04
  • I have way less crashes, when I synchronised with lock usages of renderer. – Szymon Klimaszewski Nov 04 '20 at 14:58
  • After one week of beta test on ~3K devices this type of error is virtually disappeared! This was the correct solution! Thank you! – mspnr Nov 17 '20 at 21:31