]> git.parisson.com Git - pdf.js.git/commitdiff
Fixing concurent draw page requests for de-allocation
authorYury Delendik <ydelendik@mozilla.com>
Mon, 16 Apr 2012 19:13:41 +0000 (14:13 -0500)
committerYury Delendik <ydelendik@mozilla.com>
Mon, 16 Apr 2012 19:13:41 +0000 (14:13 -0500)
src/api.js
web/viewer.js

index f4c42f48cbf2ddcfe242fb9c5f14f7bc61605cb5..1bebce28d865e990f355e71cc63aba4cf540f797 100644 (file)
@@ -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;
index 68f0a6a338f8e942b313f37454875693bcd9e815..a25a2a3ce3c86901fb9e8f2c62565c6383e9131b 100644 (file)
@@ -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';