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

Update PdfPage.java #46

Closed
wants to merge 1 commit into from
Closed

Update PdfPage.java #46

wants to merge 1 commit into from

Conversation

ouani
Copy link

@ouani ouani commented Jul 1, 2014

Hey,

First of all, thanks a lot for that tremendous component you provided.

I ran into a regular crash when i was using the component to display various pdf file : on the left pane the name of the file and when the user click on a name, the pdf is displayed on the right.

Switching quickly between files to display led me into a RunTimeException in the function :

static PdfPage createPage(long dochandle, int pageno)
{
return new PdfPage(open(dochandle, pageno), dochandle);
}

in org.vudroid.pdfdroid.codec.PdfPage

A little investigation led me to find that this happened when two threads was calling this function at the same time.

Just added a "synchronized" qualifier on the function and that bug was gone.

I ran into a regular crash when i was using the component to display various pdf file : on the left pane the name of the file and when the user click on a name, the pdf is displayed on the right.

Switching quickly between files to display led me into a RunTimeException in the function : 

static PdfPage createPage(long dochandle, int pageno)
    {
        return new PdfPage(open(dochandle, pageno), dochandle);
    }

in org.vudroid.pdfdroid.codec.PdfPage

A little investigation led me to find that this happened when two threads was calling this function at the same time.

Just added a "synchronized" qualifier on the function and that bug was gone.
@JoanZapata
Copy link
Owner

I already know about concurrency issues but pdfview is supposed to take care of that using a worker thread to render all pdf pages. So you spotted a bug.

Using synchronized would slow down this thread so I would rather not use it, but instead understand why the component created 2 worker threads.

@JoanZapata JoanZapata closed this Jul 2, 2014
@ouani
Copy link
Author

ouani commented Jul 2, 2014

Rodger :) !

@JoanZapata
Copy link
Owner

Are you using multiple PDFView or reusing one?

@ouani
Copy link
Author

ouani commented Jul 2, 2014

Reusing one. I've tried forcing recycle between two .fromFile, setting the View to Null and finding it again. No change. When i switch between file at a slow rate, the problem doesn't occur.

@JoanZapata JoanZapata mentioned this pull request Jul 2, 2014
@RoelRoel
Copy link

Is there a way to completly kill the PDFview before loading a new PDF file as a work-around?
Wil removing the view from the parent and re-adding it help?

edit: It seems to work for me! :-)

@nrallakis
Copy link

Thank you RoelRoel for your tip!
I had been struggling with this problem!
Recycling the pdfview onSaveInstanceState solved it!

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.

None yet

4 participants