简体   繁体   English

修复旧 Android 版本的 PDFium 崩溃或包含自己的库

[英]Repair PDFium crashes for old Android versions or include own library

I have an Android app which uses the standard PdfRenderer to render PDFs.我有一个 Android 应用程序,它使用标准的PdfRenderer来呈现 PDF。 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.它以多种变体(不仅是 FPDF_CloseDocument)发生,并且在日常会话中产生高达 4% 的崩溃。 The problem is encountered on Android versions from 5 to 8 on various devices.在各种设备上从 5 到 8 的 Android 版本上都会遇到该问题。

After some searching, it appears, that PDFium library (on which PdfRenderer is based on) had some bugs in earlier versions.经过一番搜索,发现PDFium库( PdfRenderer所基于的库)在早期版本中存在一些错误。 That's why the problem is not appearing on Android versions 9 and 10.这就是为什么这个问题没有出现在 Android 9 和 10 版本上的原因。

So my practical task is to get rid of 11 SIGSEGV crashes .所以我的实际任务是摆脱 11 SIGSEGV crashes

Here I have the following ideas:在这里,我有以下想法:

  1. Include the latest version of PDFium into my app.将最新版本的 PDFium 包含到我的应用程序中。 Currently libpdfium.so is included to Android OS.目前 libpdfium.so 包含在 Android 操作系统中。 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?在哪里可以找到 libpdfium.so 以及如何在应用程序中使用它?

  2. Use an alternative PDF renderer.使用替代的 PDF 渲染器。 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.我需要以所需的缩放比例和分辨率渲染 PDF 页面的一部分,并且我需要像 MIT 或 Apache 这样非常松散的许可证,所以我不需要开源我的项目。 I didn't find any appropriate, eg MuPDF requires to open source the whole your project, PSPDFKit is fully proprietary.我没有找到任何合适的,例如MuPDF需要开源整个项目, PSPDFKit是完全专有的。

What way is better to get rid of 11 SIGSEGV crashes?有什么方法可以更好地摆脱 11 次 SIGSEGV 崩溃?

检查您的线程并确保没有并发问题,根据文档它不是线程安全的: https : //developer.android.com/reference/android/graphics/pdf/PdfRenderer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM