Check if pageView.pdfPage
exists in PDFViewer._ensurePdfPageLoaded
, to avoid potentially calling PDFPageView.setPdfPage
multiple times for the same page
Since calling `PDFPageView.setPdfPage` will in turn call `PDFPageView.reset`, which cancels all rendering and completely resets the page, it's thus possible that we currently cause some unnecessary re-rendering during the initial loading phase of the viewer. Depending on the order in which data arrives, it's possible (and in practice always seem to happen) that the `pdfPage` property of the *second* page has already been set during `PDFViewer.setDocument`, by the time that the request for the `pdfPage` is resolved in `PDFViewer._ensurePdfPageLoaded`. Also, note how the `setPdfPage` call in `PDFViewer.setDocument` is already guarded by this kind of check.
This commit is contained in:
parent
b0a4f6de8f
commit
fce2cfddcf
@ -843,12 +843,13 @@ var PDFViewer = (function pdfViewer() {
|
||||
if (this._pagesRequests[pageNumber]) {
|
||||
return this._pagesRequests[pageNumber];
|
||||
}
|
||||
var promise = this.pdfDocument.getPage(pageNumber).then(
|
||||
function (pdfPage) {
|
||||
pageView.setPdfPage(pdfPage);
|
||||
var promise = this.pdfDocument.getPage(pageNumber).then((pdfPage) => {
|
||||
if (!pageView.pdfPage) {
|
||||
pageView.setPdfPage(pdfPage);
|
||||
}
|
||||
this._pagesRequests[pageNumber] = null;
|
||||
return pdfPage;
|
||||
}.bind(this));
|
||||
});
|
||||
this._pagesRequests[pageNumber] = promise;
|
||||
return promise;
|
||||
},
|
||||
@ -859,9 +860,9 @@ var PDFViewer = (function pdfViewer() {
|
||||
this._pages,
|
||||
this.scroll.down);
|
||||
if (pageView) {
|
||||
this._ensurePdfPageLoaded(pageView).then(function () {
|
||||
this._ensurePdfPageLoaded(pageView).then(() => {
|
||||
this.renderingQueue.renderView(pageView);
|
||||
}.bind(this));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user