We ran into an issue posted on Rollbar and figured out it's happening when the PDFView zoom animation is, playing due to a double tap, and the user dismisses the PDFView. Our parent view, which is a Dialog-based class, contains a button to close the PDFView and Dialog. The user can also click the Back button to do the same action.
We fixed this by overriding our onBackPressed() in the parent Dialog as well as that dismiss button and checking if the view PDFView.isZooming() If it is, we PDFView.resetZoomWithAnimation() instead of dismissing.
I'm posting it here just in case maintainers would like to enhance the PDFView to avoid the crash. If you don't see this as an issue, feel free to close, or let me know if you'd like me to close it.
java.lang.NullPointerException: Attempt to read from field 'long com.shockwave.pdfium.PdfDocument.mNativeDocPtr' on a null object reference
1 at com.shockwave.pdfium.PdfiumCore.openPage (PdfiumCore.java:166)
2 at com.github.barteksc.pdfviewer.PDFView.loadPage (PDFView.java:706)
3 at com.github.barteksc.pdfviewer.PDFView.loadPages (PDFView.java:664)
4 at com.github.barteksc.pdfviewer.AnimationManager$ZoomAnimation.onAnimationEnd (AnimationManager.java:153)
We ran into an issue posted on Rollbar and figured out it's happening when the PDFView zoom animation is, playing due to a double tap, and the user dismisses the PDFView. Our parent view, which is a
Dialog
-based class, contains a button to close the PDFView and Dialog. The user can also click the Back button to do the same action.We fixed this by overriding our
onBackPressed()
in the parent Dialog as well as that dismiss button and checking if the viewPDFView.isZooming()
If it is, wePDFView.resetZoomWithAnimation()
instead of dismissing.I'm posting it here just in case maintainers would like to enhance the PDFView to avoid the crash. If you don't see this as an issue, feel free to close, or let me know if you'd like me to close it.
Thanks, Anthony
Versions of library in use
Stacktrace