Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check null to solve crash #2

Closed
wants to merge 3 commits into from
Closed

check null to solve crash #2

wants to merge 3 commits into from

Conversation

YOEL311
Copy link

@YOEL311 YOEL311 commented Dec 27, 2021

get crash
Android OS: 9<

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'boolean android.os.HandlerThread.isAlive()' on a null object reference

com.github.barteksc.pdfviewer.PDFView.loadComplete (PDFView.java:756)
com.github.barteksc.pdfviewer.DecodingAsyncTask.onPostExecute (DecodingAsyncTask.java:80)
com.github.barteksc.pdfviewer.DecodingAsyncTask.onPostExecute (DecodingAsyncTask.java:27)
android.os.AsyncTask.finish (AsyncTask.java:755)
android.os.AsyncTask.access$900 (AsyncTask.java:192)
android.os.AsyncTask$InternalHandler.handleMessage (AsyncTask.java:772)
android.os.Handler.dispatchMessage (Handler.java:107)
android.os.Looper.loop (Looper.java:237)
android.app.ActivityThread.main (ActivityThread.java:8167)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:496)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1100)

Copy link
Owner

@mhiew mhiew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @YOEL311, thanks for investigating and putting up a PR!

I'll keep the guard statement which might protect against the NPE. 👍
This might stop crashes, but I have a feeling it will not fix the root issue and some of your users may not be able to load pdfs.

I took a look at the original repo and think that the issue is probably due to this

I'll implement the fix of moving thread creation from the constructor into onAttachedToWindow.

I am also a bit hesitant to integrate any of the gradle changes so I will likely leave those out for now.

mhiew added a commit that referenced this pull request Dec 27, 2021
- the thread creation and recycling was not being handled symmetrically
- this fix is based off of these two PR: DImuthuUpe#824 and #2
@mhiew
Copy link
Owner

mhiew commented Dec 27, 2021

I am going to close this for now.

Hopefully the change here helps address the issue you were facing.

@mhiew mhiew closed this Dec 27, 2021
@YOEL311
Copy link
Author

YOEL311 commented Jan 2, 2022

Thanks,
It passed my tough QA
💪🏼. 😀

AhmerAfzal1 added a commit to AhmerAfzal1/AhmerPdfium that referenced this pull request Feb 14, 2022
Fix a potential NPE due to out of sync render thread management [Pull Request](DImuthuUpe/AndroidPdfViewer#824)
Update the sample app configuration so that it can compile [Pull Request](mhiew/AndroidPdfViewer#2)
facundofernandez added a commit to facundofernandez/AndroidPdfViewer that referenced this pull request Sep 13, 2024
- the thread creation and recycling was not being handled symmetrically
- this fix is based off of these two PR: DImuthuUpe#824 and mhiew#2
ref: DImuthuUpe@41f912e
facundofernandez added a commit to GoIntegro/AndroidPdfViewer that referenced this pull request Sep 16, 2024
- the thread creation and recycling was not being handled symmetrically
- this fix is based off of these two PR: DImuthuUpe#824 and mhiew#2
ref: DImuthuUpe/AndroidPdfViewer@41f912e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants