Pdf-Viewer icon indicating copy to clipboard operation
Pdf-Viewer copied to clipboard

[BUG] Opening PDF via URL, and then pressing device back button causes app to crash.

Open sumit-joshi28 opened this issue 2 years ago • 8 comments

📝 Describe the Bug

I am loading one PDF URL and while it is in a loading state, I press the device back button. And then reload the same URL and I am getting this crash. I am using Jetpack Compose PdfRendererViewCompose() to load the URL.

FATAL EXCEPTION: main Process: se.ctek.ctekapp, PID: 7596 java.io.IOException: file not in PDF format or corrupted at android.graphics.pdf.PdfRenderer.nativeCreate(Native Method) at android.graphics.pdf.PdfRenderer.<init>(PdfRenderer.java:172) at com.rajat.pdfviewer.PdfRendererCore.openPdfFile(PdfRendererCore.kt:132) at com.rajat.pdfviewer.PdfRendererCore.<init>(PdfRendererCore.kt:48) at com.rajat.pdfviewer.PdfRendererView.init(PdfRendererView.kt:130) at com.rajat.pdfviewer.PdfRendererView.initWithFile(PdfRendererView.kt:101) at com.rajat.pdfviewer.PdfRendererView$initWithUrl$1.onDownloadSuccess(PdfRendererView.kt:90) at com.rajat.pdfviewer.PdfDownloader.checkAndDownload(PdfDownloader.kt:53) at com.rajat.pdfviewer.PdfDownloader.access$checkAndDownload(PdfDownloader.kt:12) at com.rajat.pdfviewer.PdfDownloader$1.invokeSuspend(PdfDownloader.kt:30) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367) at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30) at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25) at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:110) at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56) at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1) at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47) at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1) at com.rajat.pdfviewer.PdfDownloader.<init>(PdfDownloader.kt:30) at com.rajat.pdfviewer.PdfRendererView.initWithUrl(PdfRendererView.kt:78)

📖 Library Version

  • version v2.0.4

🚶 Steps to Reproduce

Please follow these steps to reproduce the issue:

  1. Open PdfViewer with a URL containing pdf.
  2. Before fully loading immediately navigate to the back screen.
  3. Repeat the step 1, you will find a crash.

sumit-joshi28 avatar Dec 28 '23 10:12 sumit-joshi28

Thank you for creating your first issue. We appreciate your help in making this project better. We will look into it, and get back to you soon.

github-actions[bot] avatar Dec 28 '23 10:12 github-actions[bot]

Hi Do you mind sending me your PDF url, if its not confidential.

afreakyelf avatar Dec 29 '23 04:12 afreakyelf

This doesn't look like a particular PDF problem, you can check with any large PDF directly loading from the HTTP URL and while it is loading press the back button and load it again, that way you can reproduce the problem.

sumit-joshi28 avatar Dec 29 '23 04:12 sumit-joshi28

@afreakyelf Hi, were you able to reproduce the problem?

sumit-joshi28 avatar Jan 03 '24 05:01 sumit-joshi28

+1 , works fine on an higer end device i.e S21, crashes on lower end devices like Asus Zenfone Max Pro M1

Update: now it stopped happening. No code changes.

DarkAbhi avatar Jan 18 '24 07:01 DarkAbhi

@DarkAbhi Did you try the exact steps as mentioned?

sumit-joshi28 avatar Jan 18 '24 12:01 sumit-joshi28

@DarkAbhi Did you try the exact steps as mentioned?

Yes.

DarkAbhi avatar Jan 22 '24 11:01 DarkAbhi

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Feb 22 '24 02:02 github-actions[bot]

Great, thanks @DarkAbhi

afreakyelf avatar Feb 27 '24 04:02 afreakyelf