Bug 880140 - Avoid crash on Mac. r=bdahl, a=bajaj
authorYury Delendik <ydelendik@mozilla.com>
Thu, 22 Aug 2013 18:44:10 -0500
changeset 153875 e51ab0350b5a62eb68455c763c54b079cefc0f02
parent 153874 ff2350045919d727d337f92a7632c1b7dedf69bc
child 153876 c5082a9b33b1465b3338ebf40382888aa766dd87
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl, bajaj
bugs880140
milestone25.0a2
Bug 880140 - Avoid crash on Mac. r=bdahl, a=bajaj
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/web/viewer.js
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -3043,17 +3043,17 @@ function addContextCurrentTransform(ctx)
   }
 }
 
 var CachedCanvases = (function CachedCanvasesClosure() {
   var cache = {};
   return {
     getCanvas: function CachedCanvases_getCanvas(id, width, height) {
       var canvas;
-      if (id in cache) {
+      if (id in cache && !PDFJS.noCachedCanvases) {
         canvas = cache[id];
         canvas.width = width;
         canvas.height = height;
         // reset canvas transform for emulated mozCurrentTransform, if needed
         canvas.getContext('2d').setTransform(1, 0, 0, 1, 0, 0);
       } else {
         canvas = createScratchCanvas(width, height);
         cache[id] = canvas;
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -2938,29 +2938,33 @@ var PageView = function pageView(contain
       ctx.restore();
       ctx.scale(PRINT_OUTPUT_SCALE, PRINT_OUTPUT_SCALE);
 
       var renderContext = {
         canvasContext: ctx,
         viewport: viewport
       };
 
+      // HACK to avoid crash on Mac, see bug 880140
+      PDFJS.noCachedCanvases = /Mac OS X/.test(navigator.userAgent);
       pdfPage.render(renderContext).then(function() {
         // Tell the printEngine that rendering this canvas/page has finished.
         obj.done();
         self.pdfPage.destroy();
+        delete PDFJS.noCachedCanvases;
       }, function(error) {
         console.error(error);
         // Tell the printEngine that rendering this canvas/page has failed.
         // This will make the print proces stop.
         if ('abort' in obj)
           obj.abort();
         else
           obj.done();
         self.pdfPage.destroy();
+        delete PDFJS.noCachedCanvases;
       });
     };
   };
 
   this.updateStats = function pageViewUpdateStats() {
     if (!this.stats) {
       return;
     }