Bug 1641916 - Update pdf.js to version 2.6.2. r=bdahl
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 03 Jun 2020 16:07:02 +0000
changeset 533718 def2048db7b56f9e3ae7162d35f90d505c5d11af
parent 533717 442db4dc7416adb3a124ebb9881b81e7f3b5dfae
child 533719 ea5fb8a9f0cdbc92ee60c5316f0ddcd98e53aac2
push id37476
push userccoroiu@mozilla.com
push dateWed, 03 Jun 2020 21:49:22 +0000
treeherdermozilla-central@66d3efe9fc7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1641916
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1641916 - Update pdf.js to version 2.6.2. r=bdahl Differential Revision: https://phabricator.services.mozilla.com/D77480
browser/extensions/pdfjs/README.mozilla
browser/extensions/pdfjs/content/build/pdf.js
browser/extensions/pdfjs/content/build/pdf.worker.js
browser/extensions/pdfjs/content/web/viewer.js
browser/extensions/pdfjs/moz.yaml
--- a/browser/extensions/pdfjs/README.mozilla
+++ b/browser/extensions/pdfjs/README.mozilla
@@ -1,5 +1,5 @@
 This is the PDF.js project output, https://github.com/mozilla/pdf.js
 
-Current extension version is: 2.5.179
+Current extension version is: 2.6.2
 
-Taken from upstream commit: 604a6f96a
+Taken from upstream commit: 8fc1126b5
--- a/browser/extensions/pdfjs/content/build/pdf.js
+++ b/browser/extensions/pdfjs/content/build/pdf.js
@@ -229,22 +229,16 @@ Object.defineProperty(exports, "InvalidP
   }
 });
 Object.defineProperty(exports, "MissingPDFException", {
   enumerable: true,
   get: function () {
     return _util.MissingPDFException;
   }
 });
-Object.defineProperty(exports, "NativeImageDecoding", {
-  enumerable: true,
-  get: function () {
-    return _util.NativeImageDecoding;
-  }
-});
 Object.defineProperty(exports, "OPS", {
   enumerable: true,
   get: function () {
     return _util.OPS;
   }
 });
 Object.defineProperty(exports, "PasswordResponses", {
   enumerable: true,
@@ -336,18 +330,18 @@ var _annotation_layer = __w_pdfjs_requir
 var _api_compatibility = __w_pdfjs_require__(7);
 
 var _worker_options = __w_pdfjs_require__(10);
 
 var _text_layer = __w_pdfjs_require__(17);
 
 var _svg = __w_pdfjs_require__(18);
 
-const pdfjsVersion = '2.5.179';
-const pdfjsBuild = '604a6f96a';
+const pdfjsVersion = '2.6.2';
+const pdfjsBuild = '8fc1126b5';
 ;
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -356,17 +350,16 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.addLinkAttributes = addLinkAttributes;
 exports.getFilenameFromUrl = getFilenameFromUrl;
 exports.isFetchSupported = isFetchSupported;
 exports.isValidFetchUrl = isValidFetchUrl;
 exports.loadScript = loadScript;
 exports.deprecated = deprecated;
-exports.releaseImageResources = releaseImageResources;
 exports.PDFDateString = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
 const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
 exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
 const SVG_NS = "http://www.w3.org/2000/svg";
 
@@ -749,27 +742,16 @@ function loadScript(src) {
     (document.head || document.documentElement).appendChild(script);
   });
 }
 
 function deprecated(details) {
   console.log("Deprecated API usage: " + details);
 }
 
-function releaseImageResources(img) {
-  (0, _util.assert)(img instanceof Image, "Invalid `img` parameter.");
-  const url = img.src;
-
-  if (typeof url === "string" && url.startsWith("blob:") && URL.revokeObjectURL) {
-    URL.revokeObjectURL(url);
-  }
-
-  img.removeAttribute("src");
-}
-
 let pdfDateStringRegex;
 
 class PDFDateString {
   static toDateObject(input) {
     if (!input || !(0, _util.isString)(input)) {
       return null;
     }
 
@@ -845,30 +827,24 @@ exports.setVerbosityLevel = setVerbosity
 exports.shadow = shadow;
 exports.string32 = string32;
 exports.stringToBytes = stringToBytes;
 exports.stringToPDFString = stringToPDFString;
 exports.stringToUTF8String = stringToUTF8String;
 exports.utf8StringToString = utf8StringToString;
 exports.warn = warn;
 exports.unreachable = unreachable;
-exports.IsEvalSupportedCached = exports.IsLittleEndianCached = exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
+exports.IsEvalSupportedCached = exports.IsLittleEndianCached = exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
 
 __w_pdfjs_require__(3);
 
 const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
 exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
 const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
 exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
-const NativeImageDecoding = {
-  NONE: "none",
-  DECODE: "decode",
-  DISPLAY: "display"
-};
-exports.NativeImageDecoding = NativeImageDecoding;
 const PermissionFlag = {
   PRINT: 0x04,
   MODIFY_CONTENTS: 0x08,
   COPY: 0x10,
   MODIFY_ANNOTATIONS: 0x20,
   FILL_INTERACTIVE_FORMS: 0x100,
   COPY_FOR_ACCESSIBILITY: 0x200,
   ASSEMBLE: 0x400,
@@ -1779,21 +1755,16 @@ function getDocument(src) {
     params[key] = source[key];
   }
 
   params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
   params.CMapReaderFactory = params.CMapReaderFactory || _display_utils.DOMCMapReaderFactory;
   params.ignoreErrors = params.stopAtErrors !== true;
   params.fontExtraProperties = params.fontExtraProperties === true;
   params.pdfBug = params.pdfBug === true;
-  const NativeImageDecoderValues = Object.values(_util.NativeImageDecoding);
-
-  if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
-    params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE;
-  }
 
   if (!Number.isInteger(params.maxImageSize)) {
     params.maxImageSize = -1;
   }
 
   if (typeof params.isEvalSupported !== "boolean") {
     params.isEvalSupported = true;
   }
@@ -1809,20 +1780,16 @@ function getDocument(src) {
   if (typeof params.disableStream !== "boolean") {
     params.disableStream = false;
   }
 
   if (typeof params.disableAutoFetch !== "boolean") {
     params.disableAutoFetch = false;
   }
 
-  if (typeof params.disableCreateObjectURL !== "boolean") {
-    params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false;
-  }
-
   (0, _util.setVerbosityLevel)(params.verbosity);
 
   if (!worker) {
     const workerParams = {
       verbosity: params.verbosity,
       port: _worker_options.GlobalWorkerOptions.workerPort
     };
     worker = workerParams.port ? PDFWorker.fromPort(workerParams) : new PDFWorker(workerParams);
@@ -1885,31 +1852,29 @@ function _fetchDocument(worker, source, 
   if (pdfDataRangeTransport) {
     source.length = pdfDataRangeTransport.length;
     source.initialData = pdfDataRangeTransport.initialData;
     source.progressiveDone = pdfDataRangeTransport.progressiveDone;
   }
 
   return worker.messageHandler.sendWithPromise("GetDocRequest", {
     docId,
-    apiVersion: '2.5.179',
+    apiVersion: '2.6.2',
     source: {
       data: source.data,
       url: source.url,
       password: source.password,
       disableAutoFetch: source.disableAutoFetch,
       rangeChunkSize: source.rangeChunkSize,
       length: source.length
     },
     maxImageSize: source.maxImageSize,
     disableFontFace: source.disableFontFace,
-    disableCreateObjectURL: source.disableCreateObjectURL,
     postMessageTransfers: worker.postMessageTransfers,
     docBaseUrl: source.docBaseUrl,
-    nativeImageDecoderSupport: source.nativeImageDecoderSupport,
     ignoreErrors: source.ignoreErrors,
     isEvalSupported: source.isEvalSupported,
     fontExtraProperties: source.fontExtraProperties
   }).then(function (workerId) {
     if (worker.destroyed) {
       throw new Error("Worker was destroyed");
     }
 
@@ -3280,16 +3245,17 @@ class WorkerTransport {
             }
 
             this.commonObjs.resolve(id, font);
           });
           break;
 
         case "FontPath":
         case "FontType3Res":
+        case "Image":
           this.commonObjs.resolve(id, exportedData);
           break;
 
         default:
           throw new Error(`Got unknown common object type ${type}`);
       }
     });
     messageHandler.on("obj", data => {
@@ -3300,34 +3266,16 @@ class WorkerTransport {
       const [id, pageIndex, type, imageData] = data;
       const pageProxy = this.pageCache[pageIndex];
 
       if (pageProxy.objs.has(id)) {
         return undefined;
       }
 
       switch (type) {
-        case "JpegStream":
-          return new Promise((resolve, reject) => {
-            const img = new Image();
-
-            img.onload = function () {
-              resolve(img);
-            };
-
-            img.onerror = function () {
-              reject(new Error("Error during JPEG image loading"));
-              (0, _display_utils.releaseImageResources)(img);
-            };
-
-            img.src = imageData;
-          }).then(img => {
-            pageProxy.objs.resolve(id, img);
-          });
-
         case "Image":
           pageProxy.objs.resolve(id, imageData);
           const MAX_IMAGE_SIZE_TO_STORE = 8000000;
 
           if (imageData && "data" in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
             pageProxy.cleanupAfterRender = true;
           }
 
@@ -3347,79 +3295,16 @@ class WorkerTransport {
       if (loadingTask.onProgress) {
         loadingTask.onProgress({
           loaded: data.loaded,
           total: data.total
         });
       }
     });
     messageHandler.on("UnsupportedFeature", this._onUnsupportedFeature.bind(this));
-    messageHandler.on("JpegDecode", ([imageUrl, components]) => {
-      if (this.destroyed) {
-        return Promise.reject(new Error("Worker was destroyed"));
-      }
-
-      if (typeof document === "undefined") {
-        return Promise.reject(new Error('"document" is not defined.'));
-      }
-
-      if (components !== 3 && components !== 1) {
-        return Promise.reject(new Error("Only 3 components or 1 component can be returned"));
-      }
-
-      return new Promise(function (resolve, reject) {
-        const img = new Image();
-
-        img.onload = function () {
-          const {
-            width,
-            height
-          } = img;
-          const size = width * height;
-          const rgbaLength = size * 4;
-          const buf = new Uint8ClampedArray(size * components);
-          let tmpCanvas = document.createElement("canvas");
-          tmpCanvas.width = width;
-          tmpCanvas.height = height;
-          let tmpCtx = tmpCanvas.getContext("2d");
-          tmpCtx.drawImage(img, 0, 0);
-          const data = tmpCtx.getImageData(0, 0, width, height).data;
-
-          if (components === 3) {
-            for (let i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
-              buf[j] = data[i];
-              buf[j + 1] = data[i + 1];
-              buf[j + 2] = data[i + 2];
-            }
-          } else if (components === 1) {
-            for (let i = 0, j = 0; i < rgbaLength; i += 4, j++) {
-              buf[j] = data[i];
-            }
-          }
-
-          resolve({
-            data: buf,
-            width,
-            height
-          });
-          (0, _display_utils.releaseImageResources)(img);
-          tmpCanvas.width = 0;
-          tmpCanvas.height = 0;
-          tmpCanvas = null;
-          tmpCtx = null;
-        };
-
-        img.onerror = function () {
-          reject(new Error("JpegDecode failed to load image"));
-          (0, _display_utils.releaseImageResources)(img);
-        };
-
-        img.src = imageUrl;
-      });
-    });
     messageHandler.on("FetchBuiltInCMap", (data, sink) => {
       if (this.destroyed) {
         sink.error(new Error("Worker was destroyed"));
         return;
       }
 
       let fetched = false;
 
@@ -3578,19 +3463,17 @@ class WorkerTransport {
       this.fontLoader.clear();
     });
   }
 
   get loadingParams() {
     const params = this._params;
     return (0, _util.shadow)(this, "loadingParams", {
       disableAutoFetch: params.disableAutoFetch,
-      disableCreateObjectURL: params.disableCreateObjectURL,
-      disableFontFace: params.disableFontFace,
-      nativeImageDecoderSupport: params.nativeImageDecoderSupport
+      disableFontFace: params.disableFontFace
     });
   }
 
 }
 
 class PDFObjects {
   constructor() {
     this._objs = Object.create(null);
@@ -3633,26 +3516,16 @@ class PDFObjects {
     const obj = this._ensureObj(objId);
 
     obj.resolved = true;
     obj.data = data;
     obj.capability.resolve(data);
   }
 
   clear() {
-    for (const objId in this._objs) {
-      const {
-        data
-      } = this._objs[objId];
-
-      if (typeof Image !== "undefined" && data instanceof Image) {
-        (0, _display_utils.releaseImageResources)(data);
-      }
-    }
-
     this._objs = Object.create(null);
   }
 
 }
 
 class RenderTask {
   constructor(internalRenderTask) {
     this._internalRenderTask = internalRenderTask;
@@ -3830,19 +3703,19 @@ const InternalRenderTask = function Inte
       }
     }
 
   }
 
   return InternalRenderTask;
 }();
 
-const version = '2.5.179';
+const version = '2.6.2';
 exports.version = version;
-const build = '604a6f96a';
+const build = '8fc1126b5';
 exports.build = build;
 
 /***/ }),
 /* 6 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
@@ -5885,43 +5758,16 @@ var CanvasGraphics = function CanvasGrap
       }
 
       this.transform.apply(this, transform);
       this.transform.apply(this, matrix);
     },
     endAnnotation: function CanvasGraphics_endAnnotation() {
       this.restore();
     },
-    paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
-      const domImage = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
-
-      if (!domImage) {
-        (0, _util.warn)("Dependent image isn't ready yet");
-        return;
-      }
-
-      this.save();
-      var ctx = this.ctx;
-      ctx.scale(1 / w, -1 / h);
-      ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
-
-      if (this.imageLayer) {
-        var currentTransform = ctx.mozCurrentTransformInverse;
-        var position = this.getCanvasPosition(0, 0);
-        this.imageLayer.appendImage({
-          objId,
-          left: position[0],
-          top: position[1],
-          width: w / currentTransform[0],
-          height: h / currentTransform[3]
-        });
-      }
-
-      this.restore();
-    },
     paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
       var ctx = this.ctx;
       var width = img.width,
           height = img.height;
       var fillColor = this.current.fillColor;
       var isPatternFill = this.current.patternFill;
       var glyph = this.processingType3;
 
@@ -5995,27 +5841,27 @@ var CanvasGraphics = function CanvasGrap
         ctx.save();
         ctx.transform.apply(ctx, image.transform);
         ctx.scale(1, -1);
         ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
         ctx.restore();
       }
     },
     paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
-      const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
+      const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
 
       if (!imgData) {
         (0, _util.warn)("Dependent image isn't ready yet");
         return;
       }
 
       this.paintInlineImageXObject(imgData);
     },
     paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
-      const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
+      const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
 
       if (!imgData) {
         (0, _util.warn)("Dependent image isn't ready yet");
         return;
       }
 
       var width = imgData.width;
       var height = imgData.height;
--- a/browser/extensions/pdfjs/content/build/pdf.worker.js
+++ b/browser/extensions/pdfjs/content/build/pdf.worker.js
@@ -130,18 +130,18 @@ Object.defineProperty(exports, "WorkerMe
   enumerable: true,
   get: function () {
     return _worker.WorkerMessageHandler;
   }
 });
 
 var _worker = __w_pdfjs_require__(1);
 
-const pdfjsVersion = '2.5.179';
-const pdfjsBuild = '604a6f96a';
+const pdfjsVersion = '2.6.2';
+const pdfjsBuild = '8fc1126b5';
 
 /***/ }),
 /* 1 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
@@ -226,17 +226,17 @@ var WorkerMessageHandler = {
 
   createDocumentHandler(docParams, port) {
     var pdfManager;
     var terminated = false;
     var cancelXHRs = null;
     var WorkerTasks = [];
     const verbosity = (0, _util.getVerbosityLevel)();
     const apiVersion = docParams.apiVersion;
-    const workerVersion = '2.5.179';
+    const workerVersion = '2.6.2';
 
     if (apiVersion !== workerVersion) {
       throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
     }
 
     var docId = docParams.docId;
     var docBaseUrl = docParams.docBaseUrl;
     var workerHandlerName = docParams.docId + "_worker";
@@ -444,20 +444,18 @@ var WorkerMessageHandler = {
             ensureNotTerminated();
             loadDocument(true).then(onSuccess, onFailure);
           });
         }, onFailure);
       }
 
       ensureNotTerminated();
       var evaluatorOptions = {
-        forceDataSchema: data.disableCreateObjectURL,
         maxImageSize: data.maxImageSize,
         disableFontFace: data.disableFontFace,
-        nativeImageDecoderSupport: data.nativeImageDecoderSupport,
         ignoreErrors: data.ignoreErrors,
         isEvalSupported: data.isEvalSupported,
         fontExtraProperties: data.fontExtraProperties
       };
       getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
         if (terminated) {
           newPdfManager.terminate(new _util.AbortException("Worker was terminated."));
           throw new Error("Worker was terminated");
@@ -612,17 +610,17 @@ var WorkerMessageHandler = {
           sink.error(reason);
         });
       });
     });
     handler.on("FontFallback", function (data) {
       return pdfManager.fontFallback(data.id, handler);
     });
     handler.on("Cleanup", function wphCleanup(data) {
-      return pdfManager.cleanup();
+      return pdfManager.cleanup(true);
     });
     handler.on("Terminate", function wphTerminate(data) {
       terminated = true;
       const waitOn = [];
 
       if (pdfManager) {
         pdfManager.terminate(new _util.AbortException("Worker was terminated."));
         const cleanupPromise = pdfManager.cleanup();
@@ -699,30 +697,24 @@ exports.setVerbosityLevel = setVerbosity
 exports.shadow = shadow;
 exports.string32 = string32;
 exports.stringToBytes = stringToBytes;
 exports.stringToPDFString = stringToPDFString;
 exports.stringToUTF8String = stringToUTF8String;
 exports.utf8StringToString = utf8StringToString;
 exports.warn = warn;
 exports.unreachable = unreachable;
-exports.IsEvalSupportedCached = exports.IsLittleEndianCached = exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
+exports.IsEvalSupportedCached = exports.IsLittleEndianCached = exports.createObjectURL = exports.FormatError = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.MissingPDFException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationStateModelType = exports.AnnotationReviewState = exports.AnnotationReplyType = exports.AnnotationMarkedState = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = exports.BaseException = void 0;
 
 __w_pdfjs_require__(3);
 
 const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
 exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
 const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
 exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
-const NativeImageDecoding = {
-  NONE: "none",
-  DECODE: "decode",
-  DISPLAY: "display"
-};
-exports.NativeImageDecoding = NativeImageDecoding;
 const PermissionFlag = {
   PRINT: 0x04,
   MODIFY_CONTENTS: 0x08,
   COPY: 0x10,
   MODIFY_ANNOTATIONS: 0x20,
   FILL_INTERACTIVE_FORMS: 0x100,
   COPY_FOR_ACCESSIBILITY: 0x200,
   ASSEMBLE: 0x400,
@@ -1775,16 +1767,20 @@ var RefSet = function RefSetClosure() {
 exports.RefSet = RefSet;
 
 var RefSetCache = function RefSetCacheClosure() {
   function RefSetCache() {
     this.dict = Object.create(null);
   }
 
   RefSetCache.prototype = {
+    get size() {
+      return Object.keys(this.dict).length;
+    },
+
     get: function RefSetCache_get(ref) {
       return this.dict[ref.toString()];
     },
     has: function RefSetCache_has(ref) {
       return ref.toString() in this.dict;
     },
     put: function RefSetCache_put(ref, obj) {
       this.dict[ref.toString()] = obj;
@@ -1914,18 +1910,18 @@ class BasePdfManager {
   getPage(pageIndex) {
     return this.pdfDocument.getPage(pageIndex);
   }
 
   fontFallback(id, handler) {
     return this.pdfDocument.fontFallback(id, handler);
   }
 
-  cleanup() {
-    return this.pdfDocument.cleanup();
+  cleanup(manuallyTriggered = false) {
+    return this.pdfDocument.cleanup(manuallyTriggered);
   }
 
   async ensure(obj, prop, args) {
     (0, _util.unreachable)("Abstract method `ensure` called");
   }
 
   requestRange(begin, end) {
     (0, _util.unreachable)("Abstract method `requestRange` called");
@@ -2816,27 +2812,27 @@ var _util = __w_pdfjs_require__(2);
 var _obj = __w_pdfjs_require__(10);
 
 var _primitives = __w_pdfjs_require__(5);
 
 var _core_utils = __w_pdfjs_require__(8);
 
 var _stream = __w_pdfjs_require__(12);
 
-var _annotation = __w_pdfjs_require__(24);
+var _annotation = __w_pdfjs_require__(25);
 
 var _crypto = __w_pdfjs_require__(22);
 
 var _parser = __w_pdfjs_require__(11);
 
-var _operator_list = __w_pdfjs_require__(25);
-
-var _evaluator = __w_pdfjs_require__(26);
-
-var _function = __w_pdfjs_require__(40);
+var _operator_list = __w_pdfjs_require__(26);
+
+var _evaluator = __w_pdfjs_require__(27);
+
+var _function = __w_pdfjs_require__(41);
 
 const DEFAULT_USER_UNIT = 1.0;
 const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
 
 function isAnnotationRenderable(annotation, intent) {
   return intent === "display" && annotation.viewable || intent === "print" && annotation.printable;
 }
 
@@ -2844,25 +2840,27 @@ class Page {
   constructor({
     pdfManager,
     xref,
     pageIndex,
     pageDict,
     ref,
     fontCache,
     builtInCMapCache,
+    globalImageCache,
     pdfFunctionFactory
   }) {
     this.pdfManager = pdfManager;
     this.pageIndex = pageIndex;
     this.pageDict = pageDict;
     this.xref = xref;
     this.ref = ref;
     this.fontCache = fontCache;
     this.builtInCMapCache = builtInCMapCache;
+    this.globalImageCache = globalImageCache;
     this.pdfFunctionFactory = pdfFunctionFactory;
     this.evaluatorOptions = pdfManager.evaluatorOptions;
     this.resourcesPromise = null;
     const idCounters = {
       obj: 0
     };
     this.idFactory = {
       createObjId() {
@@ -3015,16 +3013,17 @@ class Page {
     const resourcesPromise = this.loadResources(["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"]);
     const partialEvaluator = new _evaluator.PartialEvaluator({
       xref: this.xref,
       handler,
       pageIndex: this.pageIndex,
       idFactory: this.idFactory,
       fontCache: this.fontCache,
       builtInCMapCache: this.builtInCMapCache,
+      globalImageCache: this.globalImageCache,
       options: this.evaluatorOptions,
       pdfFunctionFactory: this.pdfFunctionFactory
     });
     const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
     const pageListPromise = dataPromises.then(([contentStream]) => {
       const opList = new _operator_list.OperatorList(intent, sink, this.pageIndex);
       handler.send("StartRenderPage", {
         transparency: partialEvaluator.hasBlendModes(this.resources),
@@ -3088,16 +3087,17 @@ class Page {
     return dataPromises.then(([contentStream]) => {
       const partialEvaluator = new _evaluator.PartialEvaluator({
         xref: this.xref,
         handler,
         pageIndex: this.pageIndex,
         idFactory: this.idFactory,
         fontCache: this.fontCache,
         builtInCMapCache: this.builtInCMapCache,
+        globalImageCache: this.globalImageCache,
         options: this.evaluatorOptions,
         pdfFunctionFactory: this.pdfFunctionFactory
       });
       return partialEvaluator.getTextContent({
         stream: contentStream,
         task,
         resources: this.resources,
         normalizeWhitespace,
@@ -3511,16 +3511,17 @@ class PDFDocument {
       return new Page({
         pdfManager: this.pdfManager,
         xref: this.xref,
         pageIndex,
         pageDict,
         ref,
         fontCache: catalog.fontCache,
         builtInCMapCache: catalog.builtInCMapCache,
+        globalImageCache: catalog.globalImageCache,
         pdfFunctionFactory: this.pdfFunctionFactory
       });
     });
   }
 
   checkFirstPage() {
     return this.getPage(0).catch(async reason => {
       if (reason instanceof _core_utils.XRefEntryException) {
@@ -3530,18 +3531,18 @@ class PDFDocument {
       }
     });
   }
 
   fontFallback(id, handler) {
     return this.catalog.fontFallback(id, handler);
   }
 
-  async cleanup() {
-    return this.catalog ? this.catalog.cleanup() : (0, _primitives.clearPrimitiveCaches)();
+  async cleanup(manuallyTriggered = false) {
+    return this.catalog ? this.catalog.cleanup(manuallyTriggered) : (0, _primitives.clearPrimitiveCaches)();
   }
 
 }
 
 exports.PDFDocument = PDFDocument;
 
 /***/ }),
 /* 10 */
@@ -3562,32 +3563,35 @@ var _primitives = __w_pdfjs_require__(5)
 var _parser = __w_pdfjs_require__(11);
 
 var _core_utils = __w_pdfjs_require__(8);
 
 var _crypto = __w_pdfjs_require__(22);
 
 var _colorspace = __w_pdfjs_require__(23);
 
+var _image_utils = __w_pdfjs_require__(24);
+
 function fetchDestination(dest) {
   return (0, _primitives.isDict)(dest) ? dest.get("D") : dest;
 }
 
 class Catalog {
   constructor(pdfManager, xref) {
     this.pdfManager = pdfManager;
     this.xref = xref;
     this.catDict = xref.getCatalogObj();
 
     if (!(0, _primitives.isDict)(this.catDict)) {
       throw new _util.FormatError("Catalog object is not a dictionary.");
     }
 
     this.fontCache = new _primitives.RefSetCache();
     this.builtInCMapCache = new Map();
+    this.globalImageCache = new _image_utils.GlobalImageCache();
     this.pageKidsCountCache = new _primitives.RefSetCache();
   }
 
   get metadata() {
     const streamRef = this.catDict.getRaw("Metadata");
 
     if (!(0, _primitives.isRef)(streamRef)) {
       return (0, _util.shadow)(this, "metadata", null);
@@ -4273,18 +4277,19 @@ class Catalog {
         if (translatedFont.loadedName === id) {
           translatedFont.fallback(handler);
           return;
         }
       }
     });
   }
 
-  cleanup() {
+  cleanup(manuallyTriggered = false) {
     (0, _primitives.clearPrimitiveCaches)();
+    this.globalImageCache.clear(manuallyTriggered);
     this.pageKidsCountCache.clear();
     const promises = [];
     this.fontCache.forEach(function (promise) {
       promises.push(promise);
     });
     return Promise.all(promises).then(translatedFonts => {
       for (const {
         dict
@@ -11831,24 +11836,24 @@ exports.ArithmeticDecoder = ArithmeticDe
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.JpegStream = void 0;
 
-var _util = __w_pdfjs_require__(2);
-
 var _stream = __w_pdfjs_require__(12);
 
 var _primitives = __w_pdfjs_require__(5);
 
 var _jpg = __w_pdfjs_require__(19);
 
+var _util = __w_pdfjs_require__(2);
+
 const JpegStream = function JpegStreamClosure() {
   function JpegStream(stream, maybeLength, dict, params) {
     let ch;
 
     while ((ch = stream.getByte()) !== -1) {
       if (ch === 0xff) {
         stream.skip(-1);
         break;
@@ -11921,136 +11926,16 @@ const JpegStream = function JpegStreamCl
       forceRGB: this.forceRGB,
       isSourcePDF: true
     });
     this.buffer = data;
     this.bufferLength = data.length;
     this.eof = true;
   };
 
-  Object.defineProperty(JpegStream.prototype, "maybeValidDimensions", {
-    get: function JpegStream_maybeValidDimensions() {
-      const {
-        dict,
-        stream
-      } = this;
-      const dictHeight = dict.get("Height", "H");
-      const startPos = stream.pos;
-      let validDimensions = true,
-          foundSOF = false,
-          b;
-
-      while ((b = stream.getByte()) !== -1) {
-        if (b !== 0xff) {
-          continue;
-        }
-
-        switch (stream.getByte()) {
-          case 0xc0:
-          case 0xc1:
-          case 0xc2:
-            foundSOF = true;
-            stream.pos += 2;
-            stream.pos += 1;
-            const scanLines = stream.getUint16();
-            const samplesPerLine = stream.getUint16();
-
-            if (scanLines * samplesPerLine > 1e6) {
-              validDimensions = false;
-              break;
-            }
-
-            if (scanLines === dictHeight) {
-              break;
-            }
-
-            if (scanLines === 0) {
-              validDimensions = false;
-              break;
-            }
-
-            if (scanLines > dictHeight * 10) {
-              validDimensions = false;
-              break;
-            }
-
-            break;
-
-          case 0xc3:
-          case 0xc5:
-          case 0xc6:
-          case 0xc7:
-          case 0xc9:
-          case 0xca:
-          case 0xcb:
-          case 0xcd:
-          case 0xce:
-          case 0xcf:
-            foundSOF = true;
-            break;
-
-          case 0xc4:
-          case 0xcc:
-          case 0xda:
-          case 0xdb:
-          case 0xdc:
-          case 0xdd:
-          case 0xde:
-          case 0xdf:
-          case 0xe0:
-          case 0xe1:
-          case 0xe2:
-          case 0xe3:
-          case 0xe4:
-          case 0xe5:
-          case 0xe6:
-          case 0xe7:
-          case 0xe8:
-          case 0xe9:
-          case 0xea:
-          case 0xeb:
-          case 0xec:
-          case 0xed:
-          case 0xee:
-          case 0xef:
-          case 0xfe:
-            const markerLength = stream.getUint16();
-
-            if (markerLength > 2) {
-              stream.skip(markerLength - 2);
-            } else {
-              stream.skip(-2);
-            }
-
-            break;
-
-          case 0xff:
-            stream.skip(-1);
-            break;
-
-          case 0xd9:
-            foundSOF = true;
-            break;
-        }
-
-        if (foundSOF) {
-          break;
-        }
-      }
-
-      stream.pos = startPos;
-      return (0, _util.shadow)(this, "maybeValidDimensions", validDimensions);
-    },
-    configurable: true
-  });
-
-  JpegStream.prototype.getIR = function (forceDataSchema = false) {
-    return (0, _util.createObjectURL)(this.bytes, "image/jpeg", forceDataSchema);
-  };
-
   return JpegStream;
 }();
 
 exports.JpegStream = JpegStream;
 
 /***/ }),
 /* 19 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
@@ -18356,30 +18241,185 @@ const LabCS = function LabCSClosure() {
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
+exports.GlobalImageCache = exports.LocalImageCache = void 0;
+
+var _util = __w_pdfjs_require__(2);
+
+var _primitives = __w_pdfjs_require__(5);
+
+class LocalImageCache {
+  constructor() {
+    this._nameRefMap = new Map();
+    this._imageMap = new Map();
+    this._imageCache = new _primitives.RefSetCache();
+  }
+
+  getByName(name) {
+    const ref = this._nameRefMap.get(name);
+
+    if (ref) {
+      return this.getByRef(ref);
+    }
+
+    return this._imageMap.get(name) || null;
+  }
+
+  getByRef(ref) {
+    return this._imageCache.get(ref) || null;
+  }
+
+  set(name, ref = null, data) {
+    if (!name) {
+      throw new Error('LocalImageCache.set - expected "name" argument.');
+    }
+
+    if (ref) {
+      if (this._imageCache.has(ref)) {
+        return;
+      }
+
+      this._nameRefMap.set(name, ref);
+
+      this._imageCache.put(ref, data);
+
+      return;
+    }
+
+    if (this._imageMap.has(name)) {
+      return;
+    }
+
+    this._imageMap.set(name, data);
+  }
+
+}
+
+exports.LocalImageCache = LocalImageCache;
+
+class GlobalImageCache {
+  static get NUM_PAGES_THRESHOLD() {
+    return (0, _util.shadow)(this, "NUM_PAGES_THRESHOLD", 2);
+  }
+
+  static get MAX_IMAGES_TO_CACHE() {
+    return (0, _util.shadow)(this, "MAX_IMAGES_TO_CACHE", 10);
+  }
+
+  constructor() {
+    this._refCache = new _primitives.RefSetCache();
+    this._imageCache = new _primitives.RefSetCache();
+  }
+
+  shouldCache(ref, pageIndex) {
+    const pageIndexSet = this._refCache.get(ref);
+
+    const numPages = pageIndexSet ? pageIndexSet.size + (pageIndexSet.has(pageIndex) ? 0 : 1) : 1;
+
+    if (numPages < GlobalImageCache.NUM_PAGES_THRESHOLD) {
+      return false;
+    }
+
+    if (!this._imageCache.has(ref) && this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
+      return false;
+    }
+
+    return true;
+  }
+
+  addPageIndex(ref, pageIndex) {
+    let pageIndexSet = this._refCache.get(ref);
+
+    if (!pageIndexSet) {
+      pageIndexSet = new Set();
+
+      this._refCache.put(ref, pageIndexSet);
+    }
+
+    pageIndexSet.add(pageIndex);
+  }
+
+  getData(ref, pageIndex) {
+    if (!this._refCache.has(ref)) {
+      return null;
+    }
+
+    const pageIndexSet = this._refCache.get(ref);
+
+    if (pageIndexSet.size < GlobalImageCache.NUM_PAGES_THRESHOLD) {
+      return null;
+    }
+
+    if (!this._imageCache.has(ref)) {
+      return null;
+    }
+
+    pageIndexSet.add(pageIndex);
+    return this._imageCache.get(ref);
+  }
+
+  setData(ref, data) {
+    if (!this._refCache.has(ref)) {
+      throw new Error('GlobalImageCache.setData - expected "addPageIndex" to have been called.');
+    }
+
+    if (this._imageCache.has(ref)) {
+      return;
+    }
+
+    if (this._imageCache.size >= GlobalImageCache.MAX_IMAGES_TO_CACHE) {
+      (0, _util.info)("GlobalImageCache.setData - ignoring image above MAX_IMAGES_TO_CACHE.");
+      return;
+    }
+
+    this._imageCache.put(ref, data);
+  }
+
+  clear(onlyData = false) {
+    if (!onlyData) {
+      this._refCache.clear();
+    }
+
+    this._imageCache.clear();
+  }
+
+}
+
+exports.GlobalImageCache = GlobalImageCache;
+
+/***/ }),
+/* 25 */
+/***/ (function(module, exports, __w_pdfjs_require__) {
+
+"use strict";
+
+
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
 exports.getQuadPoints = getQuadPoints;
 exports.MarkupAnnotation = exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
 var _obj = __w_pdfjs_require__(10);
 
 var _primitives = __w_pdfjs_require__(5);
 
 var _colorspace = __w_pdfjs_require__(23);
 
 var _core_utils = __w_pdfjs_require__(8);
 
-var _operator_list = __w_pdfjs_require__(25);
+var _operator_list = __w_pdfjs_require__(26);
 
 var _stream = __w_pdfjs_require__(12);
 
 class AnnotationFactory {
   static create(xref, ref, pdfManager, idFactory) {
     return pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory]);
   }
 
@@ -19430,17 +19470,17 @@ class FileAttachmentAnnotation extends M
     const file = new _obj.FileSpec(parameters.dict.get("FS"), parameters.xref);
     this.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
     this.data.file = file.serializable;
   }
 
 }
 
 /***/ }),
-/* 25 */
+/* 26 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -20092,96 +20132,94 @@ var OperatorList = function OperatorList
 
   };
   return OperatorList;
 }();
 
 exports.OperatorList = OperatorList;
 
 /***/ }),
-/* 26 */
+/* 27 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PartialEvaluator = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
-var _cmap = __w_pdfjs_require__(27);
+var _cmap = __w_pdfjs_require__(28);
 
 var _primitives = __w_pdfjs_require__(5);
 
-var _fonts = __w_pdfjs_require__(28);
-
-var _encodings = __w_pdfjs_require__(31);
+var _fonts = __w_pdfjs_require__(29);
+
+var _encodings = __w_pdfjs_require__(32);
 
 var _core_utils = __w_pdfjs_require__(8);
 
-var _unicode = __w_pdfjs_require__(34);
-
-var _standard_fonts = __w_pdfjs_require__(33);
-
-var _pattern = __w_pdfjs_require__(37);
+var _unicode = __w_pdfjs_require__(35);
+
+var _standard_fonts = __w_pdfjs_require__(34);
+
+var _pattern = __w_pdfjs_require__(38);
 
 var _parser = __w_pdfjs_require__(11);
 
-var _bidi = __w_pdfjs_require__(38);
+var _bidi = __w_pdfjs_require__(39);
 
 var _colorspace = __w_pdfjs_require__(23);
 
 var _stream = __w_pdfjs_require__(12);
 
-var _glyphlist = __w_pdfjs_require__(32);
-
-var _metrics = __w_pdfjs_require__(39);
-
-var _function = __w_pdfjs_require__(40);
-
-var _jpeg_stream = __w_pdfjs_require__(18);
-
-var _murmurhash = __w_pdfjs_require__(42);
-
-var _image_utils = __w_pdfjs_require__(43);
-
-var _operator_list = __w_pdfjs_require__(25);
+var _glyphlist = __w_pdfjs_require__(33);
+
+var _metrics = __w_pdfjs_require__(40);
+
+var _function = __w_pdfjs_require__(41);
+
+var _image_utils = __w_pdfjs_require__(24);
+
+var _murmurhash = __w_pdfjs_require__(43);
+
+var _operator_list = __w_pdfjs_require__(26);
 
 var _image = __w_pdfjs_require__(44);
 
 var PartialEvaluator = function PartialEvaluatorClosure() {
   const DefaultPartialEvaluatorOptions = {
-    forceDataSchema: false,
     maxImageSize: -1,
     disableFontFace: false,
-    nativeImageDecoderSupport: _util.NativeImageDecoding.DECODE,
     ignoreErrors: false,
     isEvalSupported: true,
     fontExtraProperties: false
   };
 
   function PartialEvaluator({
     xref,
     handler,
     pageIndex,
     idFactory,
     fontCache,
     builtInCMapCache,
+    globalImageCache,
     options = null,
     pdfFunctionFactory
   }) {
     this.xref = xref;
     this.handler = handler;
     this.pageIndex = pageIndex;
     this.idFactory = idFactory;
     this.fontCache = fontCache;
     this.builtInCMapCache = builtInCMapCache;
+    this.globalImageCache = globalImageCache;
     this.options = options || DefaultPartialEvaluatorOptions;
     this.pdfFunctionFactory = pdfFunctionFactory;
     this.parsingType3Font = false;
 
     this.fetchBuiltInCMap = async name => {
       if (this.builtInCMapCache.has(name)) {
         return this.builtInCMapCache.get(name);
       }
@@ -20538,20 +20576,20 @@ var PartialEvaluator = function PartialE
     },
 
     async buildPaintImageXObject({
       resources,
       image,
       isInline = false,
       operatorList,
       cacheKey,
-      imageCache,
-      forceDisableNativeImageDecoder = false
+      localImageCache
     }) {
       var dict = image.dict;
+      const imageRef = dict.objId;
       var w = dict.get("Width", "W");
       var h = dict.get("Height", "H");
 
       if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
         (0, _util.warn)("Image dimensions are missing, or not numbers.");
         return undefined;
       }
 
@@ -20578,130 +20616,114 @@ var PartialEvaluator = function PartialE
           imageIsFromDecodeStream: image instanceof _stream.DecodeStream,
           inverseDecode: !!decode && decode[0] > 0
         });
         imgData.cached = !!cacheKey;
         args = [imgData];
         operatorList.addOp(_util.OPS.paintImageMaskXObject, args);
 
         if (cacheKey) {
-          imageCache[cacheKey] = {
+          localImageCache.set(cacheKey, imageRef, {
             fn: _util.OPS.paintImageMaskXObject,
             args
-          };
+          });
         }
 
         return undefined;
       }
 
       var softMask = dict.get("SMask", "SM") || false;
       var mask = dict.get("Mask") || false;
       var SMALL_IMAGE_DIMENSIONS = 200;
 
-      if (isInline && !softMask && !mask && !(image instanceof _jpeg_stream.JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
+      if (isInline && !softMask && !mask && w + h < SMALL_IMAGE_DIMENSIONS) {
         const imageObj = new _image.PDFImage({
           xref: this.xref,
           res: resources,
           image,
           isInline,
           pdfFunctionFactory: this.pdfFunctionFactory
         });
         imgData = imageObj.createImageData(true);
         operatorList.addOp(_util.OPS.paintInlineImageXObject, [imgData]);
         return undefined;
       }
 
-      const nativeImageDecoderSupport = forceDisableNativeImageDecoder ? _util.NativeImageDecoding.NONE : this.options.nativeImageDecoderSupport;
-      let objId = `img_${this.idFactory.createObjId()}`;
+      let objId = `img_${this.idFactory.createObjId()}`,
+          cacheGlobally = false;
 
       if (this.parsingType3Font) {
-        (0, _util.assert)(nativeImageDecoderSupport === _util.NativeImageDecoding.NONE, "Type3 image resources should be completely decoded in the worker.");
         objId = `${this.idFactory.getDocId()}_type3res_${objId}`;
-      }
-
-      if (nativeImageDecoderSupport !== _util.NativeImageDecoding.NONE && !softMask && !mask && image instanceof _jpeg_stream.JpegStream && image.maybeValidDimensions && _image_utils.NativeImageDecoder.isSupported(image, this.xref, resources, this.pdfFunctionFactory)) {
-        return this.handler.sendWithPromise("obj", [objId, this.pageIndex, "JpegStream", image.getIR(this.options.forceDataSchema)]).then(function () {
-          operatorList.addDependency(objId);
-          args = [objId, w, h];
-          operatorList.addOp(_util.OPS.paintJpegXObject, args);
-
-          if (cacheKey) {
-            imageCache[cacheKey] = {
-              fn: _util.OPS.paintJpegXObject,
-              args
-            };
-          }
-        }, reason => {
-          (0, _util.warn)("Native JPEG decoding failed -- trying to recover: " + (reason && reason.message));
-          return this.buildPaintImageXObject({
-            resources,
-            image,
-            isInline,
-            operatorList,
-            cacheKey,
-            imageCache,
-            forceDisableNativeImageDecoder: true
-          });
-        });
-      }
-
-      var nativeImageDecoder = null;
-
-      if (nativeImageDecoderSupport === _util.NativeImageDecoding.DECODE && (image instanceof _jpeg_stream.JpegStream || mask instanceof _jpeg_stream.JpegStream || softMask instanceof _jpeg_stream.JpegStream)) {
-        nativeImageDecoder = new _image_utils.NativeImageDecoder({
-          xref: this.xref,
-          resources,
-          handler: this.handler,
-          forceDataSchema: this.options.forceDataSchema,
-          pdfFunctionFactory: this.pdfFunctionFactory
-        });
+      } else if (imageRef) {
+        cacheGlobally = this.globalImageCache.shouldCache(imageRef, this.pageIndex);
+
+        if (cacheGlobally) {
+          objId = `${this.idFactory.getDocId()}_${objId}`;
+        }
       }
 
       operatorList.addDependency(objId);
       args = [objId, w, h];
 
       const imgPromise = _image.PDFImage.buildImage({
-        handler: this.handler,
         xref: this.xref,
         res: resources,
         image,
         isInline,
-        nativeDecoder: nativeImageDecoder,
         pdfFunctionFactory: this.pdfFunctionFactory
       }).then(imageObj => {
         imgData = imageObj.createImageData(false);
 
         if (this.parsingType3Font) {
           return this.handler.sendWithPromise("commonobj", [objId, "FontType3Res", imgData], [imgData.data.buffer]);
+        } else if (cacheGlobally) {
+          this.handler.send("commonobj", [objId, "Image", imgData], [imgData.data.buffer]);
+          return undefined;
         }
 
         this.handler.send("obj", [objId, this.pageIndex, "Image", imgData], [imgData.data.buffer]);
         return undefined;
       }).catch(reason => {
         (0, _util.warn)("Unable to decode image: " + reason);
 
         if (this.parsingType3Font) {
           return this.handler.sendWithPromise("commonobj", [objId, "FontType3Res", null]);
+        } else if (cacheGlobally) {
+          this.handler.send("commonobj", [objId, "Image", null]);
+          return undefined;
         }
 
         this.handler.send("obj", [objId, this.pageIndex, "Image", null]);
         return undefined;
       });
 
       if (this.parsingType3Font) {
         await imgPromise;
       }
 
       operatorList.addOp(_util.OPS.paintImageXObject, args);
 
       if (cacheKey) {
-        imageCache[cacheKey] = {
+        localImageCache.set(cacheKey, imageRef, {
           fn: _util.OPS.paintImageXObject,
           args
-        };
+        });
+
+        if (imageRef) {
+          (0, _util.assert)(!isInline, "Cannot cache an inline image globally.");
+          this.globalImageCache.addPageIndex(imageRef, this.pageIndex);
+
+          if (cacheGlobally) {
+            this.globalImageCache.setData(imageRef, {
+              objId,
+              fn: _util.OPS.paintImageXObject,
+              args
+            });
+          }
+        }
       }
 
       return undefined;
     },
 
     handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
       var smaskContent = smask.get("G");
       var smaskOptions = {
@@ -21150,17 +21172,17 @@ var PartialEvaluator = function PartialE
 
       if (!operatorList) {
         throw new Error('getOperatorList: missing "operatorList" parameter');
       }
 
       var self = this;
       var xref = this.xref;
       let parsingText = false;
-      var imageCache = Object.create(null);
+      const localImageCache = new _image_utils.LocalImageCache();
 
       var xobjs = resources.get("XObject") || _primitives.Dict.empty;
 
       var patterns = resources.get("Pattern") || _primitives.Dict.empty;
 
       var stateManager = new StateManager(initialState);
       var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
       var timeSlotManager = new TimeSlotManager();
@@ -21199,28 +21221,53 @@ var PartialEvaluator = function PartialE
 
           var args = operation.args;
           var fn = operation.fn;
 
           switch (fn | 0) {
             case _util.OPS.paintXObject:
               var name = args[0].name;
 
-              if (name && imageCache[name] !== undefined) {
-                operatorList.addOp(imageCache[name].fn, imageCache[name].args);
-                args = null;
-                continue;
+              if (name) {
+                const localImage = localImageCache.getByName(name);
+
+                if (localImage) {
+                  operatorList.addOp(localImage.fn, localImage.args);
+                  args = null;
+                  continue;
+                }
               }
 
               next(new Promise(function (resolveXObject, rejectXObject) {
                 if (!name) {
                   throw new _util.FormatError("XObject must be referred to by name.");
                 }
 
-                const xobj = xobjs.get(name);
+                let xobj = xobjs.getRaw(name);
+
+                if (xobj instanceof _primitives.Ref) {
+                  const localImage = localImageCache.getByRef(xobj);
+
+                  if (localImage) {
+                    operatorList.addOp(localImage.fn, localImage.args);
+                    resolveXObject();
+                    return;
+                  }
+
+                  const globalImage = self.globalImageCache.getData(xobj, self.pageIndex);
+
+                  if (globalImage) {
+                    operatorList.addDependency(globalImage.objId);
+                    operatorList.addOp(globalImage.fn, globalImage.args);
+                    resolveXObject();
+                    return;
+                  }
+
+                  xobj = xref.fetch(xobj);
+                }
 
                 if (!xobj) {
                   operatorList.addOp(fn, args);
                   resolveXObject();
                   return;
                 }
 
                 if (!(0, _primitives.isStream)(xobj)) {
@@ -21241,17 +21288,17 @@ var PartialEvaluator = function PartialE
                   }, rejectXObject);
                   return;
                 } else if (type.name === "Image") {
                   self.buildPaintImageXObject({
                     resources,
                     image: xobj,
                     operatorList,
                     cacheKey: name,
-                    imageCache
+                    localImageCache
                   }).then(resolveXObject, rejectXObject);
                   return;
                 } else if (type.name === "PS") {
                   (0, _util.info)("Ignored XObject subtype PS");
                 } else {
                   throw new _util.FormatError(`Unhandled XObject subtype ${type.name}`);
                 }
 
@@ -21288,32 +21335,32 @@ var PartialEvaluator = function PartialE
             case _util.OPS.endText:
               parsingText = false;
               break;
 
             case _util.OPS.endInlineImage:
               var cacheKey = args[0].cacheKey;
 
               if (cacheKey) {
-                var cacheEntry = imageCache[cacheKey];
-
-                if (cacheEntry !== undefined) {
-                  operatorList.addOp(cacheEntry.fn, cacheEntry.args);
+                const localImage = localImageCache.getByName(cacheKey);
+
+                if (localImage) {
+                  operatorList.addOp(localImage.fn, localImage.args);
                   args = null;
                   continue;
                 }
               }
 
               next(self.buildPaintImageXObject({
                 resources,
                 image: args[0],
                 isInline: true,
                 operatorList,
                 cacheKey,
-                imageCache
+                localImageCache
               }));
               return;
 
             case _util.OPS.showText:
               if (!stateManager.state.font) {
                 self.ensureStateFont(stateManager.state);
                 continue;
               }
@@ -21596,17 +21643,17 @@ var PartialEvaluator = function PartialE
         fontName: null
       };
       var SPACE_FACTOR = 0.3;
       var MULTI_SPACE_FACTOR = 1.5;
       var MULTI_SPACE_FACTOR_MAX = 4;
       var self = this;
       var xref = this.xref;
       var xobjs = null;
-      var skipEmptyXObjs = Object.create(null);
+      const emptyXObjectCache = new _image_utils.LocalImageCache();
       var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
       var textState;
 
       function ensureTextContentItem() {
         if (textContentItem.initialized) {
           return textContentItem;
         }
 
@@ -22021,26 +22068,35 @@ var PartialEvaluator = function PartialE
               flushTextContentItem();
 
               if (!xobjs) {
                 xobjs = resources.get("XObject") || _primitives.Dict.empty;
               }
 
               var name = args[0].name;
 
-              if (name && skipEmptyXObjs[name] !== undefined) {
+              if (name && emptyXObjectCache.getByName(name)) {
                 break;
               }
 
               next(new Promise(function (resolveXObject, rejectXObject) {
                 if (!name) {
                   throw new _util.FormatError("XObject must be referred to by name.");
                 }
 
-                const xobj = xobjs.get(name);
+                let xobj = xobjs.getRaw(name);
+
+                if (xobj instanceof _primitives.Ref) {
+                  if (emptyXObjectCache.getByRef(xobj)) {
+                    resolveXObject();
+                    return;
+                  }
+
+                  xobj = xref.fetch(xobj);
+                }
 
                 if (!xobj) {
                   resolveXObject();
                   return;
                 }
 
                 if (!(0, _primitives.isStream)(xobj)) {
                   throw new _util.FormatError("XObject should be a stream");
@@ -22048,17 +22104,17 @@ var PartialEvaluator = function PartialE
 
                 const type = xobj.dict.get("Subtype");
 
                 if (!(0, _primitives.isName)(type)) {
                   throw new _util.FormatError("XObject should have a Name subtype");
                 }
 
                 if (type.name !== "Form") {
-                  skipEmptyXObjs[name] = true;
+                  emptyXObjectCache.set(name, xobj.dict.objId, true);
                   resolveXObject();
                   return;
                 }
 
                 const currentState = stateManager.state.clone();
                 const xObjStateManager = new StateManager(currentState);
                 const matrix = xobj.dict.getArray("Matrix");
 
@@ -22090,17 +22146,17 @@ var PartialEvaluator = function PartialE
                   resources: xobj.dict.get("Resources") || resources,
                   stateManager: xObjStateManager,
                   normalizeWhitespace,
                   combineTextItems,
                   sink: sinkWrapper,
                   seenStyles
                 }).then(function () {
                   if (!sinkWrapper.enqueueInvoked) {
-                    skipEmptyXObjs[name] = true;
+                    emptyXObjectCache.set(name, xobj.dict.objId, true);
                   }
 
                   resolveXObject();
                 }, rejectXObject);
               }).catch(function (reason) {
                 if (reason instanceof _util.AbortException) {
                   return;
                 }
@@ -22993,17 +23049,16 @@ class TranslatedFont {
     }
 
     if (this.type3Loaded) {
       return this.type3Loaded;
     }
 
     var type3Options = Object.create(evaluator.options);
     type3Options.ignoreErrors = false;
-    type3Options.nativeImageDecoderSupport = _util.NativeImageDecoding.NONE;
     var type3Evaluator = evaluator.clone(type3Options);
     type3Evaluator.parsingType3Font = true;
     var translatedFont = this.font;
     var loadCharProcsPromise = Promise.resolve();
     var charProcs = this.dict.get("CharProcs");
     var fontResources = this.dict.get("Resources") || resources;
     var charProcKeys = charProcs.getKeys();
     var charProcOperatorList = Object.create(null);
@@ -23676,17 +23731,17 @@ var EvaluatorPreprocessor = function Eva
           break;
       }
     }
   };
   return EvaluatorPreprocessor;
 }();
 
 /***/ }),
-/* 27 */
+/* 28 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -23698,16 +23753,17 @@ var _primitives = __w_pdfjs_require__(5)
 
 var _parser = __w_pdfjs_require__(11);
 
 var _core_utils = __w_pdfjs_require__(8);
 
 var _stream = __w_pdfjs_require__(12);
 
 var BUILT_IN_CMAPS = ["Adobe-GB1-UCS2", "Adobe-CNS1-UCS2", "Adobe-Japan1-UCS2", "Adobe-Korea1-UCS2", "78-EUC-H", "78-EUC-V", "78-H", "78-RKSJ-H", "78-RKSJ-V", "78-V", "78ms-RKSJ-H", "78ms-RKSJ-V", "83pv-RKSJ-H", "90ms-RKSJ-H", "90ms-RKSJ-V", "90msp-RKSJ-H", "90msp-RKSJ-V", "90pv-RKSJ-H", "90pv-RKSJ-V", "Add-H", "Add-RKSJ-H", "Add-RKSJ-V", "Add-V", "Adobe-CNS1-0", "Adobe-CNS1-1", "Adobe-CNS1-2", "Adobe-CNS1-3", "Adobe-CNS1-4", "Adobe-CNS1-5", "Adobe-CNS1-6", "Adobe-GB1-0", "Adobe-GB1-1", "Adobe-GB1-2", "Adobe-GB1-3", "Adobe-GB1-4", "Adobe-GB1-5", "Adobe-Japan1-0", "Adobe-Japan1-1", "Adobe-Japan1-2", "Adobe-Japan1-3", "Adobe-Japan1-4", "Adobe-Japan1-5", "Adobe-Japan1-6", "Adobe-Korea1-0", "Adobe-Korea1-1", "Adobe-Korea1-2", "B5-H", "B5-V", "B5pc-H", "B5pc-V", "CNS-EUC-H", "CNS-EUC-V", "CNS1-H", "CNS1-V", "CNS2-H", "CNS2-V", "ETHK-B5-H", "ETHK-B5-V", "ETen-B5-H", "ETen-B5-V", "ETenms-B5-H", "ETenms-B5-V", "EUC-H", "EUC-V", "Ext-H", "Ext-RKSJ-H", "Ext-RKSJ-V", "Ext-V", "GB-EUC-H", "GB-EUC-V", "GB-H", "GB-V", "GBK-EUC-H", "GBK-EUC-V", "GBK2K-H", "GBK2K-V", "GBKp-EUC-H", "GBKp-EUC-V", "GBT-EUC-H", "GBT-EUC-V", "GBT-H", "GBT-V", "GBTpc-EUC-H", "GBTpc-EUC-V", "GBpc-EUC-H", "GBpc-EUC-V", "H", "HKdla-B5-H", "HKdla-B5-V", "HKdlb-B5-H", "HKdlb-B5-V", "HKgccs-B5-H", "HKgccs-B5-V", "HKm314-B5-H", "HKm314-B5-V", "HKm471-B5-H", "HKm471-B5-V", "HKscs-B5-H", "HKscs-B5-V", "Hankaku", "Hiragana", "KSC-EUC-H", "KSC-EUC-V", "KSC-H", "KSC-Johab-H", "KSC-Johab-V", "KSC-V", "KSCms-UHC-H", "KSCms-UHC-HW-H", "KSCms-UHC-HW-V", "KSCms-UHC-V", "KSCpc-EUC-H", "KSCpc-EUC-V", "Katakana", "NWP-H", "NWP-V", "RKSJ-H", "RKSJ-V", "Roman", "UniCNS-UCS2-H", "UniCNS-UCS2-V", "UniCNS-UTF16-H", "UniCNS-UTF16-V", "UniCNS-UTF32-H", "UniCNS-UTF32-V", "UniCNS-UTF8-H", "UniCNS-UTF8-V", "UniGB-UCS2-H", "UniGB-UCS2-V", "UniGB-UTF16-H", "UniGB-UTF16-V", "UniGB-UTF32-H", "UniGB-UTF32-V", "UniGB-UTF8-H", "UniGB-UTF8-V", "UniJIS-UCS2-H", "UniJIS-UCS2-HW-H", "UniJIS-UCS2-HW-V", "UniJIS-UCS2-V", "UniJIS-UTF16-H", "UniJIS-UTF16-V", "UniJIS-UTF32-H", "UniJIS-UTF32-V", "UniJIS-UTF8-H", "UniJIS-UTF8-V", "UniJIS2004-UTF16-H", "UniJIS2004-UTF16-V", "UniJIS2004-UTF32-H", "UniJIS2004-UTF32-V", "UniJIS2004-UTF8-H", "UniJIS2004-UTF8-V", "UniJISPro-UCS2-HW-V", "UniJISPro-UCS2-V", "UniJISPro-UTF8-V", "UniJISX0213-UTF32-H", "UniJISX0213-UTF32-V", "UniJISX02132004-UTF32-H", "UniJISX02132004-UTF32-V", "UniKS-UCS2-H", "UniKS-UCS2-V", "UniKS-UTF16-H", "UniKS-UTF16-V", "UniKS-UTF32-H", "UniKS-UTF32-V", "UniKS-UTF8-H", "UniKS-UTF8-V", "V", "WP-Symbol"];
+const MAX_MAP_RANGE = 2 ** 24 - 1;
 
 class CMap {
   constructor(builtInCMap = false) {
     this.codespaceRanges = [[], [], [], []];
     this.numCodespaceRanges = 0;
     this._map = [];
     this.name = "";
     this.vertical = false;
@@ -23716,31 +23772,43 @@ class CMap {
   }
 
   addCodespaceRange(n, low, high) {
     this.codespaceRanges[n - 1].push(low, high);
     this.numCodespaceRanges++;
   }
 
   mapCidRange(low, high, dstLow) {
+    if (high - low > MAX_MAP_RANGE) {
+      throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");
+    }
+
     while (low <= high) {
       this._map[low++] = dstLow++;
     }
   }
 
   mapBfRange(low, high, dstLow) {
+    if (high - low > MAX_MAP_RANGE) {
+      throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");
+    }
+
     var lastByte = dstLow.length - 1;
 
     while (low <= high) {
       this._map[low++] = dstLow;
       dstLow = dstLow.substring(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
     }
   }
 
   mapBfRangeToArray(low, high, array) {
+    if (high - low > MAX_MAP_RANGE) {
+      throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");
+    }
+
     const ii = array.length;
     let i = 0;
 
     while (low <= high && i < ii) {
       this._map[low] = array[i++];
       ++low;
     }
   }
@@ -24573,49 +24641,49 @@ var CMapFactory = function CMapFactoryCl
     }
 
   };
 }();
 
 exports.CMapFactory = CMapFactory;
 
 /***/ }),
-/* 28 */
+/* 29 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.getFontType = getFontType;
 exports.IdentityToUnicodeMap = exports.ToUnicodeMap = exports.FontFlags = exports.Font = exports.ErrorFont = exports.SEAC_ANALYSIS_ENABLED = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
-var _cff_parser = __w_pdfjs_require__(29);
-
-var _glyphlist = __w_pdfjs_require__(32);
-
-var _encodings = __w_pdfjs_require__(31);
-
-var _standard_fonts = __w_pdfjs_require__(33);
-
-var _unicode = __w_pdfjs_require__(34);
+var _cff_parser = __w_pdfjs_require__(30);
+
+var _glyphlist = __w_pdfjs_require__(33);
+
+var _encodings = __w_pdfjs_require__(32);
+
+var _standard_fonts = __w_pdfjs_require__(34);
+
+var _unicode = __w_pdfjs_require__(35);
 
 var _core_utils = __w_pdfjs_require__(8);
 
-var _font_renderer = __w_pdfjs_require__(35);
-
-var _cmap = __w_pdfjs_require__(27);
+var _font_renderer = __w_pdfjs_require__(36);
+
+var _cmap = __w_pdfjs_require__(28);
 
 var _stream = __w_pdfjs_require__(12);
 
-var _type1_parser = __w_pdfjs_require__(36);
+var _type1_parser = __w_pdfjs_require__(37);
 
 const PRIVATE_USE_AREAS = [[0xe000, 0xf8ff], [0x100000, 0x10fffd]];
 var PDF_GLYPH_SPACE_UNITS = 1000;
 var SEAC_ANALYSIS_ENABLED = true;
 exports.SEAC_ANALYSIS_ENABLED = SEAC_ANALYSIS_ENABLED;
 const EXPORT_DATA_PROPERTIES = ["ascent", "bbox", "black", "bold", "charProcOperatorList", "composite", "data", "defaultVMetrics", "defaultWidth", "descent", "fallbackName", "fontMatrix", "fontType", "isMonospace", "isSerifFont", "isType3Font", "italic", "loadedName", "mimetype", "missingFile", "name", "remeasure", "subtype", "type", "vertical"];
 const EXPORT_DATA_EXTRA_PROPERTIES = ["cMap", "defaultEncoding", "differences", "isSymbolicFont", "seacMap", "toFontChar", "toUnicode", "vmetrics", "widths"];
 var FontFlags = {
@@ -27813,32 +27881,32 @@ var CFFFont = function CFFFontClosure() 
     hasGlyphId: function CFFFont_hasGlyphID(id) {
       return this.cff.hasGlyphId(id);
     }
   };
   return CFFFont;
 }();
 
 /***/ }),
-/* 29 */
+/* 30 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.CFFFDSelect = exports.CFFCompiler = exports.CFFPrivateDict = exports.CFFTopDict = exports.CFFCharset = exports.CFFIndex = exports.CFFStrings = exports.CFFHeader = exports.CFF = exports.CFFParser = exports.CFFStandardStrings = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
-var _charsets = __w_pdfjs_require__(30);
-
-var _encodings = __w_pdfjs_require__(31);
+var _charsets = __w_pdfjs_require__(31);
+
+var _encodings = __w_pdfjs_require__(32);
 
 var MAX_SUBR_NESTING = 10;
 var CFFStandardStrings = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall", "001.000", "001.001", "001.002", "001.003", "Black", "Bold", "Book", "Light", "Medium", "Regular", "Roman", "Semibold"];
 exports.CFFStandardStrings = CFFStandardStrings;
 const NUM_STANDARD_CFF_STRINGS = 391;
 
 var CFFParser = function CFFParserClosure() {
   var CharstringValidationData = [null, {
@@ -29616,17 +29684,17 @@ var CFFCompiler = function CFFCompilerCl
     }
   };
   return CFFCompiler;
 }();
 
 exports.CFFCompiler = CFFCompiler;
 
 /***/ }),
-/* 30 */
+/* 31 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -29634,17 +29702,17 @@ exports.ExpertSubsetCharset = exports.Ex
 const ISOAdobeCharset = [".notdef", "space", "exclam", "quotedbl", "numbersign", "dollar", "percent", "ampersand", "quoteright", "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash", "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash", "bracketright", "asciicircum", "underscore", "quoteleft", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar", "braceright", "asciitilde", "exclamdown", "cent", "sterling", "fraction", "yen", "florin", "section", "currency", "quotesingle", "quotedblleft", "guillemotleft", "guilsinglleft", "guilsinglright", "fi", "fl", "endash", "dagger", "daggerdbl", "periodcentered", "paragraph", "bullet", "quotesinglbase", "quotedblbase", "quotedblright", "guillemotright", "ellipsis", "perthousand", "questiondown", "grave", "acute", "circumflex", "tilde", "macron", "breve", "dotaccent", "dieresis", "ring", "cedilla", "hungarumlaut", "ogonek", "caron", "emdash", "AE", "ordfeminine", "Lslash", "Oslash", "OE", "ordmasculine", "ae", "dotlessi", "lslash", "oslash", "oe", "germandbls", "onesuperior", "logicalnot", "mu", "trademark", "Eth", "onehalf", "plusminus", "Thorn", "onequarter", "divide", "brokenbar", "degree", "thorn", "threequarters", "twosuperior", "registered", "minus", "eth", "multiply", "threesuperior", "copyright", "Aacute", "Acircumflex", "Adieresis", "Agrave", "Aring", "Atilde", "Ccedilla", "Eacute", "Ecircumflex", "Edieresis", "Egrave", "Iacute", "Icircumflex", "Idieresis", "Igrave", "Ntilde", "Oacute", "Ocircumflex", "Odieresis", "Ograve", "Otilde", "Scaron", "Uacute", "Ucircumflex", "Udieresis", "Ugrave", "Yacute", "Ydieresis", "Zcaron", "aacute", "acircumflex", "adieresis", "agrave", "aring", "atilde", "ccedilla", "eacute", "ecircumflex", "edieresis", "egrave", "iacute", "icircumflex", "idieresis", "igrave", "ntilde", "oacute", "ocircumflex", "odieresis", "ograve", "otilde", "scaron", "uacute", "ucircumflex", "udieresis", "ugrave", "yacute", "ydieresis", "zcaron"];
 exports.ISOAdobeCharset = ISOAdobeCharset;
 const ExpertCharset = [".notdef", "space", "exclamsmall", "Hungarumlautsmall", "dollaroldstyle", "dollarsuperior", "ampersandsmall", "Acutesmall", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "questionsmall", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "Circumflexsmall", "hyphensuperior", "Gravesmall", "Asmall", "Bsmall", "Csmall", "Dsmall", "Esmall", "Fsmall", "Gsmall", "Hsmall", "Ismall", "Jsmall", "Ksmall", "Lsmall", "Msmall", "Nsmall", "Osmall", "Psmall", "Qsmall", "Rsmall", "Ssmall", "Tsmall", "Usmall", "Vsmall", "Wsmall", "Xsmall", "Ysmall", "Zsmall", "colonmonetary", "onefitted", "rupiah", "Tildesmall", "exclamdownsmall", "centoldstyle", "Lslashsmall", "Scaronsmall", "Zcaronsmall", "Dieresissmall", "Brevesmall", "Caronsmall", "Dotaccentsmall", "Macronsmall", "figuredash", "hypheninferior", "Ogoneksmall", "Ringsmall", "Cedillasmall", "onequarter", "onehalf", "threequarters", "questiondownsmall", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior", "Agravesmall", "Aacutesmall", "Acircumflexsmall", "Atildesmall", "Adieresissmall", "Aringsmall", "AEsmall", "Ccedillasmall", "Egravesmall", "Eacutesmall", "Ecircumflexsmall", "Edieresissmall", "Igravesmall", "Iacutesmall", "Icircumflexsmall", "Idieresissmall", "Ethsmall", "Ntildesmall", "Ogravesmall", "Oacutesmall", "Ocircumflexsmall", "Otildesmall", "Odieresissmall", "OEsmall", "Oslashsmall", "Ugravesmall", "Uacutesmall", "Ucircumflexsmall", "Udieresissmall", "Yacutesmall", "Thornsmall", "Ydieresissmall"];
 exports.ExpertCharset = ExpertCharset;
 const ExpertSubsetCharset = [".notdef", "space", "dollaroldstyle", "dollarsuperior", "parenleftsuperior", "parenrightsuperior", "twodotenleader", "onedotenleader", "comma", "hyphen", "period", "fraction", "zerooldstyle", "oneoldstyle", "twooldstyle", "threeoldstyle", "fouroldstyle", "fiveoldstyle", "sixoldstyle", "sevenoldstyle", "eightoldstyle", "nineoldstyle", "colon", "semicolon", "commasuperior", "threequartersemdash", "periodsuperior", "asuperior", "bsuperior", "centsuperior", "dsuperior", "esuperior", "isuperior", "lsuperior", "msuperior", "nsuperior", "osuperior", "rsuperior", "ssuperior", "tsuperior", "ff", "fi", "fl", "ffi", "ffl", "parenleftinferior", "parenrightinferior", "hyphensuperior", "colonmonetary", "onefitted", "rupiah", "centoldstyle", "figuredash", "hypheninferior", "onequarter", "onehalf", "threequarters", "oneeighth", "threeeighths", "fiveeighths", "seveneighths", "onethird", "twothirds", "zerosuperior", "onesuperior", "twosuperior", "threesuperior", "foursuperior", "fivesuperior", "sixsuperior", "sevensuperior", "eightsuperior", "ninesuperior", "zeroinferior", "oneinferior", "twoinferior", "threeinferior", "fourinferior", "fiveinferior", "sixinferior", "seveninferior", "eightinferior", "nineinferior", "centinferior", "dollarinferior", "periodinferior", "commainferior"];
 exports.ExpertSubsetCharset = ExpertSubsetCharset;
 
 /***/ }),
-/* 31 */
+/* 32 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -29688,17 +29756,17 @@ function getEncoding(encodingName) {
       return MacExpertEncoding;
 
     default:
       return null;
   }
 }
 
 /***/ }),
-/* 32 */
+/* 33 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 var getLookupTableFactory = __w_pdfjs_require__(8).getLookupTableFactory;
 var getGlyphsUnicode = getLookupTableFactory(function (t) {
  t.A = 0x0041;
  t.AE = 0x00c6;
  t.AEacute = 0x01fc;
  t.AEmacron = 0x01e2;
@@ -34225,17 +34293,17 @@ var getDingbatsGlyphsUnicode = getLookup
  t.a95 = 0x2774;
  t.a96 = 0x2775;
  t[".notdef"] = 0x0000;
 });
 exports.getGlyphsUnicode = getGlyphsUnicode;
 exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
 
 /***/ }),
-/* 33 */
+/* 34 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -34969,17 +35037,17 @@ const getSupplementalGlyphMapForCalibri 
   t[1013] = 57;
   t[1081] = 37;
   t[1085] = 43;
   t[1086] = 45;
 });
 exports.getSupplementalGlyphMapForCalibri = getSupplementalGlyphMapForCalibri;
 
 /***/ }),
-/* 34 */
+/* 35 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 var getLookupTableFactory = __w_pdfjs_require__(8).getLookupTableFactory;
 var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  t[63721] = 0x00a9;
  t[63193] = 0x00a9;
  t[63720] = 0x00ae;
  t[63194] = 0x00ae;
@@ -36946,34 +37014,34 @@ function reverseIfRtl(chars) {
 }
 exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
 exports.reverseIfRtl = reverseIfRtl;
 exports.getUnicodeRangeFor = getUnicodeRangeFor;
 exports.getNormalizedUnicodes = getNormalizedUnicodes;
 exports.getUnicodeForGlyph = getUnicodeForGlyph;
 
 /***/ }),
-/* 35 */
+/* 36 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.FontRendererFactory = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
-var _cff_parser = __w_pdfjs_require__(29);
-
-var _glyphlist = __w_pdfjs_require__(32);
-
-var _encodings = __w_pdfjs_require__(31);
+var _cff_parser = __w_pdfjs_require__(30);
+
+var _glyphlist = __w_pdfjs_require__(33);
+
+var _encodings = __w_pdfjs_require__(32);
 
 var _stream = __w_pdfjs_require__(12);
 
 var FontRendererFactory = function FontRendererFactoryClosure() {
   function getLong(data, offset) {
     return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
   }
 
@@ -37912,28 +37980,28 @@ var FontRendererFactory = function FontR
       return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
     }
   };
 }();
 
 exports.FontRendererFactory = FontRendererFactory;
 
 /***/ }),
-/* 36 */
+/* 37 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.Type1Parser = void 0;
 
-var _encodings = __w_pdfjs_require__(31);
+var _encodings = __w_pdfjs_require__(32);
 
 var _core_utils = __w_pdfjs_require__(8);
 
 var _stream = __w_pdfjs_require__(12);
 
 var _util = __w_pdfjs_require__(2);
 
 var HINTING_ENABLED = false;
@@ -38623,17 +38691,17 @@ var Type1Parser = function Type1ParserCl
     }
   };
   return Type1Parser;
 }();
 
 exports.Type1Parser = Type1Parser;
 
 /***/ }),
-/* 37 */
+/* 38 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -39562,17 +39630,17 @@ function getTilingPatternIR(operatorList
   if (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
     throw new _util.FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
   }
 
   return ["TilingPattern", args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
 }
 
 /***/ }),
-/* 38 */
+/* 39 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -39874,17 +39942,17 @@ function bidi(str, startLevel, vertical)
       chars[i] = "";
     }
   }
 
   return createBidiText(chars.join(""), isLTR);
 }
 
 /***/ }),
-/* 39 */
+/* 40 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -42828,33 +42896,33 @@ var getMetrics = (0, _core_utils.getLook
     t.a189 = 927;
     t.a190 = 970;
     t.a191 = 918;
   });
 });
 exports.getMetrics = getMetrics;
 
 /***/ }),
-/* 40 */
+/* 41 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.isPDFFunction = isPDFFunction;
 exports.PostScriptCompiler = exports.PostScriptEvaluator = exports.PDFFunctionFactory = void 0;
 
 var _util = __w_pdfjs_require__(2);
 
 var _primitives = __w_pdfjs_require__(5);
 
-var _ps_parser = __w_pdfjs_require__(41);
+var _ps_parser = __w_pdfjs_require__(42);
 
 class PDFFunctionFactory {
   constructor({
     xref,
     isEvalSupported = true
   }) {
     this.xref = xref;
     this.isEvalSupported = isEvalSupported !== false;
@@ -44178,17 +44246,17 @@ var PostScriptCompiler = function PostSc
     }
   };
   return PostScriptCompiler;
 }();
 
 exports.PostScriptCompiler = PostScriptCompiler;
 
 /***/ }),
-/* 41 */
+/* 42 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -44432,17 +44500,17 @@ class PostScriptLexer {
     return value;
   }
 
 }
 
 exports.PostScriptLexer = PostScriptLexer;
 
 /***/ }),
-/* 42 */
+/* 43 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
@@ -44558,95 +44626,16 @@ class MurmurHash3_64 {
     return hex1.padStart(8, "0") + hex2.padStart(8, "0");
   }
 
 }
 
 exports.MurmurHash3_64 = MurmurHash3_64;
 
 /***/ }),
-/* 43 */
-/***/ (function(module, exports, __w_pdfjs_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.NativeImageDecoder = void 0;
-
-var _colorspace = __w_pdfjs_require__(23);
-
-var _jpeg_stream = __w_pdfjs_require__(18);
-
-var _stream = __w_pdfjs_require__(12);
-
-class NativeImageDecoder {
-  constructor({
-    xref,
-    resources,
-    handler,
-    forceDataSchema = false,
-    pdfFunctionFactory
-  }) {
-    this.xref = xref;
-    this.resources = resources;
-    this.handler = handler;
-    this.forceDataSchema = forceDataSchema;
-    this.pdfFunctionFactory = pdfFunctionFactory;
-  }
-
-  canDecode(image) {
-    return image instanceof _jpeg_stream.JpegStream && image.maybeValidDimensions && NativeImageDecoder.isDecodable(image, this.xref, this.resources, this.pdfFunctionFactory);
-  }
-
-  decode(image) {
-    const dict = image.dict;
-    let colorSpace = dict.get("ColorSpace", "CS");
-    colorSpace = _colorspace.ColorSpace.parse(colorSpace, this.xref, this.resources, this.pdfFunctionFactory);
-    return this.handler.sendWithPromise("JpegDecode", [image.getIR(this.forceDataSchema), colorSpace.numComps]).then(function ({
-      data,
-      width,
-      height
-    }) {
-      return new _stream.Stream(data, 0, data.length, dict);
-    });
-  }
-
-  static isSupported(image, xref, res, pdfFunctionFactory) {
-    const dict = image.dict;
-
-    if (dict.has("DecodeParms") || dict.has("DP")) {
-      return false;
-    }
-
-    const cs = _colorspace.ColorSpace.parse(dict.get("ColorSpace", "CS"), xref, res, pdfFunctionFactory);
-
-    return (cs.name === "DeviceGray" || cs.name === "DeviceRGB") && cs.isDefaultDecode(dict.getArray("Decode", "D"));
-  }
-
-  static isDecodable(image, xref, res, pdfFunctionFactory) {
-    const dict = image.dict;
-
-    if (dict.has("DecodeParms") || dict.has("DP")) {
-      return false;
-    }
-
-    const cs = _colorspace.ColorSpace.parse(dict.get("ColorSpace", "CS"), xref, res, pdfFunctionFactory);
-
-    const bpc = dict.get("BitsPerComponent", "BPC") || 1;
-    return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray("Decode", "D"), bpc);
-  }
-
-}
-
-exports.NativeImageDecoder = NativeImageDecoder;
-
-/***/ }),
 /* 44 */
 /***/ (function(module, exports, __w_pdfjs_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
@@ -44661,27 +44650,16 @@ var _colorspace = __w_pdfjs_require__(23
 
 var _stream = __w_pdfjs_require__(12);
 
 var _jpeg_stream = __w_pdfjs_require__(18);
 
 var _jpx = __w_pdfjs_require__(21);
 
 var PDFImage = function PDFImageClosure() {
-  function handleImageData(image, nativeDecoder) {
-    if (nativeDecoder && nativeDecoder.canDecode(image)) {
-      return nativeDecoder.decode(image).catch(reason => {
-        (0, _util.warn)("Native image decoding failed -- trying to recover: " + (reason && reason.message));
-        return image;
-      });
-    }
-
-    return Promise.resolve(image);
-  }
-
   function decodeAndClamp(value, addend, coefficient, max) {
     value = addend + value * coefficient;
 
     if (value < 0) {
       value = 0;
     } else if (value > max) {
       value = max;
     }
@@ -44868,61 +44846,47 @@ var PDFImage = function PDFImageClosure(
         }
       } else {
         this.mask = mask;
       }
     }
   }
 
   PDFImage.buildImage = function ({
-    handler,
     xref,
     res,
     image,
     isInline = false,
-    nativeDecoder = null,
     pdfFunctionFactory
   }) {
-    var imagePromise = handleImageData(image, nativeDecoder);
-    var smaskPromise;
-    var maskPromise;
-    var smask = image.dict.get("SMask");
-    var mask = image.dict.get("Mask");
+    const imageData = image;
+    let smaskData = null;
+    let maskData = null;
+    const smask = image.dict.get("SMask");
+    const mask = image.dict.get("Mask");
 
     if (smask) {
-      smaskPromise = handleImageData(smask, nativeDecoder);
-      maskPromise = Promise.resolve(null);
-    } else {
-      smaskPromise = Promise.resolve(null);
-
-      if (mask) {
-        if ((0, _primitives.isStream)(mask)) {
-          maskPromise = handleImageData(mask, nativeDecoder);
-        } else if (Array.isArray(mask)) {
-          maskPromise = Promise.resolve(mask);
-        } else {
-          (0, _util.warn)("Unsupported mask format.");
-          maskPromise = Promise.resolve(null);
-        }
-      } else {
-        maskPromise = Promise.resolve(null);
-      }
-    }
-
-    return Promise.all([imagePromise, smaskPromise, maskPromise]).then(function ([imageData, smaskData, maskData]) {
-      return new PDFImage({
-        xref,
-        res,
-        image: imageData,
-        isInline,
-        smask: smaskData,
-        mask: maskData,
-        pdfFunctionFactory
-      });
-    });
+      smaskData = smask;
+    } else if (mask) {
+      if ((0, _primitives.isStream)(mask) || Array.isArray(mask)) {
+        maskData = mask;
+      } else {
+        (0, _util.warn)("Unsupported mask format.");
+      }
+    }
+
+    return Promise.resolve(new PDFImage({
+      xref,
+      res,
+      image: imageData,
+      isInline,
+      smask: smaskData,
+      mask: maskData,
+      pdfFunctionFactory
+    }));
   };
 
   PDFImage.createMask = function ({
     imgArray,
     width,
     height,
     imageIsFromDecodeStream,
     inverseDecode
--- a/browser/extensions/pdfjs/content/web/viewer.js
+++ b/browser/extensions/pdfjs/content/web/viewer.js
@@ -275,17 +275,17 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.PDFPrintServiceFactory = exports.DefaultExternalServices = exports.PDFViewerApplication = void 0;
 
 var _ui_utils = __webpack_require__(2);
 
 var _app_options = __webpack_require__(3);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _pdf_cursor_tools = __webpack_require__(6);
 
 var _pdf_rendering_queue = __webpack_require__(8);
 
 var _pdf_sidebar = __webpack_require__(9);
 
 var _overlay_manager = __webpack_require__(10);
@@ -3364,19 +3364,17 @@ function moveToEndOfArray(arr, condition
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.OptionKind = exports.AppOptions = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
-
-var _viewer_compatibility = __webpack_require__(5);
+var _viewer_compatibility = __webpack_require__(4);
 
 const OptionKind = {
   VIEWER: 0x02,
   API: 0x04,
   WORKER: 0x08,
   PREFERENCE: 0x80
 };
 exports.OptionKind = OptionKind;
@@ -3388,16 +3386,21 @@ const defaultOptions = {
   defaultUrl: {
     value: "compressed.tracemonkey-pldi-09.pdf",
     kind: OptionKind.VIEWER
   },
   defaultZoomValue: {
     value: "",
     kind: OptionKind.VIEWER + OptionKind.PREFERENCE
   },
+  disableCreateObjectURL: {
+    value: false,
+    compatibility: _viewer_compatibility.viewerCompatibilityParams.disableCreateObjectURL,
+    kind: OptionKind.VIEWER
+  },
   disableHistory: {
     value: false,
     kind: OptionKind.VIEWER
   },
   disablePageLabels: {
     value: false,
     kind: OptionKind.VIEWER + OptionKind.PREFERENCE
   },
@@ -3485,21 +3488,16 @@ const defaultOptions = {
   cMapUrl: {
     value: "../web/cmaps/",
     kind: OptionKind.API
   },
   disableAutoFetch: {
     value: false,
     kind: OptionKind.API + OptionKind.PREFERENCE
   },
-  disableCreateObjectURL: {
-    value: false,
-    compatibility: _pdfjsLib.apiCompatibilityParams.disableCreateObjectURL,
-    kind: OptionKind.API
-  },
   disableFontFace: {
     value: false,
     kind: OptionKind.API + OptionKind.PREFERENCE
   },
   disableRange: {
     value: false,
     kind: OptionKind.API + OptionKind.PREFERENCE
   },
@@ -3609,43 +3607,43 @@ exports.AppOptions = AppOptions;
 
 /***/ }),
 /* 4 */
 /***/ (function(module, exports, __webpack_require__) {
 
 "use strict";
 
 
+Object.defineProperty(exports, "__esModule", {
+  value: true
+});
+exports.viewerCompatibilityParams = void 0;
+const compatibilityParams = Object.create(null);
+;
+const viewerCompatibilityParams = Object.freeze(compatibilityParams);
+exports.viewerCompatibilityParams = viewerCompatibilityParams;
+
+/***/ }),
+/* 5 */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
 let pdfjsLib;
 
 if (typeof window !== "undefined" && window["pdfjs-dist/build/pdf"]) {
   pdfjsLib = window["pdfjs-dist/build/pdf"];
 } else {
   pdfjsLib = require("../build/pdf.js");
 }
 
 module.exports = pdfjsLib;
 
 /***/ }),
-/* 5 */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-
-Object.defineProperty(exports, "__esModule", {
-  value: true
-});
-exports.viewerCompatibilityParams = void 0;
-const compatibilityParams = Object.create(null);
-;
-const viewerCompatibilityParams = Object.freeze(compatibilityParams);
-exports.viewerCompatibilityParams = viewerCompatibilityParams;
-
-/***/ }),
 /* 6 */
 /***/ (function(module, exports, __webpack_require__) {
 
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
@@ -4567,17 +4565,17 @@ exports.OverlayManager = OverlayManager;
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PasswordPrompt = void 0;
 
 var _ui_utils = __webpack_require__(2);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 class PasswordPrompt {
   constructor(options, overlayManager, l10n = _ui_utils.NullL10n) {
     this.overlayName = options.overlayName;
     this.container = options.container;
     this.label = options.label;
     this.input = options.input;
     this.submitButton = options.submitButton;
@@ -4644,17 +4642,17 @@ exports.PasswordPrompt = PasswordPrompt;
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFAttachmentViewer = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 class PDFAttachmentViewer {
   constructor({
     container,
     eventBus,
     downloadManager
   }) {
     this.container = container;
@@ -4679,20 +4677,16 @@ class PDFAttachmentViewer {
 
     this.eventBus.dispatch("attachmentsloaded", {
       source: this,
       attachmentsCount
     });
   }
 
   _bindPdfLink(button, content, filename) {
-    if (this.downloadManager.disableCreateObjectURL) {
-      throw new Error('bindPdfLink: Unsupported "disableCreateObjectURL" value.');
-    }
-
     let blobUrl;
 
     button.onclick = () => {
       if (!blobUrl) {
         blobUrl = URL.createObjectURL(new Blob([content], {
           type: "application/pdf"
         }));
       }
@@ -4804,17 +4798,17 @@ exports.PDFAttachmentViewer = PDFAttachm
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFDocumentProperties = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _ui_utils = __webpack_require__(2);
 
 const DEFAULT_FIELD_CONTENT = "-";
 const NON_METRIC_LOCALES = ["en-us", "en-lr", "my"];
 const US_PAGE_NAMES = {
   "8.5x11": "Letter",
   "8.5x14": "Legal"
@@ -5310,17 +5304,17 @@ exports.PDFFindBar = PDFFindBar;
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFFindController = exports.FindState = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _pdf_find_utils = __webpack_require__(16);
 
 var _ui_utils = __webpack_require__(2);
 
 const FindState = {
   FOUND: 0,
   NOT_FOUND: 1,
@@ -7114,17 +7108,17 @@ exports.SimpleLinkService = SimpleLinkSe
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFOutlineViewer = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 const DEFAULT_TITLE = "\u2013";
 
 class PDFOutlineViewer {
   constructor({
     container,
     linkService,
     eventBus
@@ -8119,17 +8113,17 @@ exports.PDFThumbnailViewer = PDFThumbnai
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFThumbnailView = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _ui_utils = __webpack_require__(2);
 
 var _pdf_rendering_queue = __webpack_require__(8);
 
 const MAX_NUM_SCALING_STEPS = 3;
 const THUMBNAIL_CANVAS_BORDER_WIDTH = 1;
 const THUMBNAIL_WIDTH = 98;
@@ -8531,17 +8525,17 @@ exports.PDFThumbnailView = PDFThumbnailV
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFViewer = void 0;
 
 var _base_viewer = __webpack_require__(25);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 class PDFViewer extends _base_viewer.BaseViewer {
   get _viewerElement() {
     return (0, _pdfjsLib.shadow)(this, "_viewerElement", this.viewer);
   }
 
   _scrollIntoView({
     pageDiv,
@@ -8622,17 +8616,17 @@ Object.defineProperty(exports, "__esModu
 exports.BaseViewer = void 0;
 
 var _ui_utils = __webpack_require__(2);
 
 var _pdf_rendering_queue = __webpack_require__(8);
 
 var _annotation_layer_builder = __webpack_require__(26);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _pdf_page_view = __webpack_require__(27);
 
 var _pdf_link_service = __webpack_require__(18);
 
 var _text_layer_builder = __webpack_require__(28);
 
 const DEFAULT_CACHE_SIZE = 10;
@@ -9736,17 +9730,17 @@ exports.BaseViewer = BaseViewer;
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.DefaultAnnotationLayerFactory = exports.AnnotationLayerBuilder = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _ui_utils = __webpack_require__(2);
 
 var _pdf_link_service = __webpack_require__(18);
 
 class AnnotationLayerBuilder {
   constructor({
     pageDiv,
@@ -9849,21 +9843,21 @@ exports.DefaultAnnotationLayerFactory = 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFPageView = void 0;
 
 var _ui_utils = __webpack_require__(2);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _pdf_rendering_queue = __webpack_require__(8);
 
-var _viewer_compatibility = __webpack_require__(5);
+var _viewer_compatibility = __webpack_require__(4);
 
 const MAX_CANVAS_PIXELS = _viewer_compatibility.viewerCompatibilityParams.maxCanvasPixels || 16777216;
 
 class PDFPageView {
   constructor(options) {
     const container = options.container;
     const defaultViewport = options.defaultViewport;
     this.id = options.id;
@@ -10416,17 +10410,17 @@ exports.PDFPageView = PDFPageView;
 "use strict";
 
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.DefaultTextLayerFactory = exports.TextLayerBuilder = void 0;
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 const EXPAND_DIVS_TIMEOUT = 300;
 
 class TextLayerBuilder {
   constructor({
     textLayerDiv,
     eventBus,
     pageIndex,
@@ -11098,17 +11092,17 @@ exports.SecondaryToolbar = SecondaryTool
 
 Object.defineProperty(exports, "__esModule", {
   value: true
 });
 exports.PDFSinglePageViewer = void 0;
 
 var _base_viewer = __webpack_require__(25);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 class PDFSinglePageViewer extends _base_viewer.BaseViewer {
   constructor(options) {
     super(options);
 
     this.eventBus._on("pagesinit", evt => {
       this._ensurePageViewVisible();
     });
@@ -11588,17 +11582,17 @@ Object.defineProperty(exports, "__esModu
   value: true
 });
 exports.FirefoxCom = exports.DownloadManager = void 0;
 
 __webpack_require__(34);
 
 var _app = __webpack_require__(1);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 var _preferences = __webpack_require__(35);
 
 var _ui_utils = __webpack_require__(2);
 
 ;
 
 const FirefoxCom = function FirefoxComClosure() {
@@ -12221,17 +12215,17 @@ Object.defineProperty(exports, "__esModu
 exports.FirefoxPrintService = FirefoxPrintService;
 
 var _app_options = __webpack_require__(3);
 
 var _ui_utils = __webpack_require__(2);
 
 var _app = __webpack_require__(1);
 
-var _pdfjsLib = __webpack_require__(4);
+var _pdfjsLib = __webpack_require__(5);
 
 function composePage(pdfDocument, pageNumber, size, printContainer) {
   const canvas = document.createElement("canvas");
   const PRINT_RESOLUTION = _app_options.AppOptions.get("printResolution") || 150;
   const PRINT_UNITS = PRINT_RESOLUTION / 72.0;
   canvas.width = Math.floor(size.width * PRINT_UNITS);
   canvas.height = Math.floor(size.height * PRINT_UNITS);
   canvas.style.width = Math.floor(size.width * _ui_utils.CSS_UNITS) + "px";
--- a/browser/extensions/pdfjs/moz.yaml
+++ b/browser/extensions/pdfjs/moz.yaml
@@ -15,15 +15,15 @@ origin:
   description: Portable Document Format (PDF) viewer that is built with HTML5
 
   # Full URL for the package's homepage/etc
   # Usually different from repository url
   url: https://github.com/mozilla/pdf.js
 
   # Human-readable identifier for this version/release
   # Generally "version NNN", "tag SSS", "bookmark SSS"
-  release: version 2.5.179
+  release: version 2.6.2
 
   # The package's license, where possible using the mnemonic from
   # https://spdx.org/licenses/
   # Multiple licenses can be specified (as a YAML list)
   # A "LICENSE" file must exist containing the full license text
   license: Apache-2.0