From 1e96c73207f3bd8a9aa1ba3443ec902f6171e27a Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 16 Apr 2012 14:13:41 -0500 Subject: [PATCH] Fixing concurent draw page requests for de-allocation --- src/api.js | 11 +++++++++-- web/viewer.js | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/api.js b/src/api.js index f4c42f48c..1bebce28d 100644 --- a/src/api.js +++ b/src/api.js @@ -203,8 +203,9 @@ var PDFPageProxy = (function PDFPageProxyClosure() { stats.time('Overall'); // If there is no displayReadyPromise yet, then the operatorList was never // requested before. Make the request and create the promise. - if (!this.displayReadyPromise) { + if (!this.displayReadyPromise || this.destroyed) { this.displayReadyPromise = new Promise(); + this.destroyed = false; this.stats.time('Page Request'); this.transport.messageHandler.send('RenderPageRequest', { @@ -250,6 +251,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { // Always defer call to display() to work around bug in // Firefox error reporting from XHR callbacks. setTimeout(function pageSetTimeout() { + delete self.operatorList; self.displayReadyPromise.resolve(); }); }; @@ -305,7 +307,6 @@ var PDFPageProxy = (function PDFPageProxyClosure() { gfx.executeOperatorList(operatorList, startIdx, next, stepper); if (startIdx == length) { gfx.endDrawing(); - delete self.operatorList; stats.timeEnd('Rendering'); stats.timeEnd('Overall'); if (callback) callback(); @@ -333,6 +334,12 @@ var PDFPageProxy = (function PDFPageProxyClosure() { }; promise.resolve(operationList); return promise; + }, + /** + * Destroys allocated by page resources. + */ + destroy: function() { + this.destroyed = true; } }; return PDFPageProxy; diff --git a/web/viewer.js b/web/viewer.js index 68f0a6a33..a25a2a3ce 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -756,6 +756,7 @@ var PageView = function pageView(container, pdfPage, id, scale, div.removeAttribute('data-loaded'); delete this.canvas; + this.pdfPage.destroy(); this.loadingIconDiv = document.createElement('div'); this.loadingIconDiv.className = 'loadingIcon';