barteksc / AndroidPdfViewerV1

Android view for displaying PDFs rendered with PdfiumAndroid
Apache License 2.0
73 stars 31 forks source link

Crash when dismissing while zooming animation plays #15

Open aavina opened 6 years ago

aavina commented 6 years ago

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.

Thanks, Anthony

Versions of library in use

implementation 'com.github.barteksc:android-pdf-viewer:1.6.0'
implementation 'com.github.barteksc:pdfium-android:1.9.0'

Stacktrace

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)