[BUG] Opening PDF via URL, and then pressing device back button causes app to crash.
📝 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:
- Open PdfViewer with a URL containing pdf.
- Before fully loading immediately navigate to the back screen.
- Repeat the step 1, you will find a crash.
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.
Hi Do you mind sending me your PDF url, if its not confidential.
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.
@afreakyelf Hi, were you able to reproduce the problem?
+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 Did you try the exact steps as mentioned?
@DarkAbhi Did you try the exact steps as mentioned?
Yes.
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.
Great, thanks @DarkAbhi