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

Reduce the number of calls to PDFView.getVisiblePages from updateViewarea #4772

Merged
merged 1 commit into from
May 12, 2014
Merged

Reduce the number of calls to PDFView.getVisiblePages from updateViewarea #4772

merged 1 commit into from
May 12, 2014

Conversation

Snuffleupagus
Copy link
Collaborator

Currently for every call to updateViewarea we call PDFView.getVisiblePages (at viewer.js#L1922) before calling PDFView.renderHighestPriority (at viewer.js#L1928); in that function we again call getVisiblePages (at viewer.js#L1215).

This means that every time when the user scrolls, we will essentially do two back-to-back calls to getVisiblePages. Given that this requires traversing the DOM to check which pages are actually visible on screen, this seem like the kind of thing you really want to avoid doing if possible (especially in long documents).

To avoid the above, I've refactored renderHighestPriority to always return the result of getVisiblePages.

@yurydelendik
Copy link
Contributor

It's somewhat unexpected for renderHighestPriority to return result of getVisiblePages. Can we change renderHighestPriority to accept visiblePages as a parameter? We can make it optional and default it to getVisiblePages call results, if needed.

@Snuffleupagus
Copy link
Collaborator Author

Can we change renderHighestPriority to accept visiblePages as a parameter?

That was actually my first idea, which I abandoned in favour of the current implementation because I felt that it was more error prone (there's no stopping anyone from calling renderHighestPriority with the "wrong" visiblePages).

If you think that's an unwarranted concern, I'll gladly change this!

@yurydelendik
Copy link
Contributor

I understand the concern, that's why I recommend and optional parameter for renderHighestPriority. I people not sure what to provide there, they will omit it. I'm afraid of reverse effect, people will start using renderHighestPriority to get visiblePages :)

@Snuffleupagus
Copy link
Collaborator Author

I've addressed the comment; so now we instead pass the visiblePages to renderHighestPriority.

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @Snuffleupagus received. Current queue size: 0

Live output at: http://107.21.233.14:8877/6f01ace1d4111ff/output.txt

@timvandermeij
Copy link
Contributor

Looks good to me. Codewise it's a cleaner solution.

timvandermeij added a commit that referenced this pull request May 12, 2014
Reduce the number of calls to PDFView.getVisiblePages from updateViewarea
@timvandermeij timvandermeij merged commit 40ba989 into mozilla:master May 12, 2014
@Snuffleupagus Snuffleupagus deleted the fewer-getVisiblePages-calls branch May 12, 2014 21:54
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