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

Address a couple of edge-cases in the new PDFHistory implementation (PR 8775 follow-up) #8885

Merged
merged 3 commits into from
Sep 8, 2017
Merged

Address a couple of edge-cases in the new PDFHistory implementation (PR 8775 follow-up) #8885

merged 3 commits into from
Sep 8, 2017

Conversation

Snuffleupagus
Copy link
Collaborator

Please refer to the individual commit messages for additional details.

Despite careful testing there's a couple of edge-case issues that managed to sneak into the new PDFHistory implementation (see PR #8775), refer in particular to the last commit, which is thus being addressed here.

…destination is scrolled into view

Since e.g. zooming can occur when navigating to a new destionation, ensure that a resulting 'updateviewarea' event doesn't trigger adding of a *temporary* position to the browser history at a bad time.
…ate' event handler to avoid subtle bugs

When testing the new `PDFHistory` implementation in practice, I felt that the current value of `UPDATE_VIEWAREA_TIMEOUT` is too large to be truly useful.
The purpose of the timeout is to attempt to address (the PDF.js part of) https://bugzilla.mozilla.org/show_bug.cgi?id=1153393, and it's currently fairly easy for the user e.g. close the browser before the timeout had a change to finish.

Obviously, the timeout is a best-effort solution, but with the current value of `UPDATE_VIEWAREA_TIMEOUT` it's not as useful as one would want.
Please note that lowering it shouldn't be a problem, since it still prevents the browser history from updating at *every* 'updateviewarea' event or during (quick) scrolling, which is all that's really needed to not impact the UX negatively.

---

Furthermore, with this lower timeout, we can also simplify the part of the 'popstate' event handler that attempted to update the browser history with the current position before moving back. In most cases, the current position will now already exist in the history, and this *greatly* decreases the complexity of this code path.

The main impetus for this change though, is that I unfortunately found that given the asynchronous nature of updating the browser history, there is some *edge* cases where that code could cause history corruption.
In practice, the user could thus get "stuck" at a particular history entry and not be able to move back. I haven't got any reliable STR for this, since it's so difficult to trigger, but it involved navigating around in a document such that a number of destinations are added to the browser history and then changing the rotation before going back/forward in the history.

Rather that attempting to patch this code, and making it even more difficult to understand than it already is or adding more asynchronous behaviour, by far the easiest solution is to remove it and simply rely on the (lowered) `UPDATE_VIEWAREA_TIMEOUT` instead.
@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Sep 8, 2017

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.67.70.0:8877/c7c938cd188c583/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Sep 8, 2017

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/c7c938cd188c583/output.txt

Total script time: 2.34 mins

Published

@timvandermeij timvandermeij merged commit c8b5ba2 into mozilla:master Sep 8, 2017
@timvandermeij
Copy link
Contributor

Thank you!

@Snuffleupagus Snuffleupagus deleted the PDFHistory-followup branch September 9, 2017 07:49
movsb pushed a commit to movsb/pdf.js that referenced this pull request Jul 14, 2018
Address a couple of edge-cases in the new `PDFHistory` implementation (PR 8775 follow-up)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants