Prevent the annotationLayer
from, in some cases, becoming duplicated on the first page when the document loads
#9001
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I don't know if this is a regression, but I noticed earlier today that depending on the initial scale and sidebar state, the
annotationLayer
of the first rendered page may end up duplicated; please see screen-shot below.I can reproduce this reliable with e.g. https://arxiv.org/pdf/1112.0542v1.pdf#zoom=page-width&pagemode=bookmarks.
When the document loads, rendering of the first page begins immediately. When the sidebar is then opened, that forces re-rendering which thus aborts rendering of the first page.
Note that calling
PDFPageView.draw()
will always, provided anAnnotationLayerFactory
instance exists, callAnnotationLayerBuilder.render()
. Hence the events described above will result in two such calls, where the actual annotation rendering/updating happens asynchronously.For reasons that I don't (at all) understand, when multiple
pdfPage.getAnnotations()
promises are handled back-to-back (inAnnotationLayerBuilder.render()
), thethis.div
property seems to not update in time for the subsequent calls.This thus, at least in Firefox, result in double rendering of all annotations on the first page.
Obviously it'd be good to find out why it breaks, since it really shouldn't, but this patch at least provides a (hopefully) acceptable work-around by ignoring
getAnnotations()
calls forAnnotationLayerBuilder
instances that we're destroying (inPDFPageView.reset()
).Edit: The patch was updated slightly to ensure that we also won't attempt to render an
annotationLayer
during closing of a PDF document, i.e. after callingPDFViewerApplication.close()
.