Merge pull request #19045 from Snuffleupagus/api-rm-isChrome
[api-minor] Disable `ImageDecoder` usage by default in Chromium browsers
This commit is contained in:
commit
e2bbcb544a
@ -84,7 +84,6 @@ const DefaultPartialEvaluatorOptions = Object.freeze({
|
|||||||
isEvalSupported: true,
|
isEvalSupported: true,
|
||||||
isOffscreenCanvasSupported: false,
|
isOffscreenCanvasSupported: false,
|
||||||
isImageDecoderSupported: false,
|
isImageDecoderSupported: false,
|
||||||
isChrome: false,
|
|
||||||
canvasMaxAreaInBytes: -1,
|
canvasMaxAreaInBytes: -1,
|
||||||
fontExtraProperties: false,
|
fontExtraProperties: false,
|
||||||
useSystemFonts: true,
|
useSystemFonts: true,
|
||||||
|
|||||||
@ -120,17 +120,13 @@ class ImageResizer {
|
|||||||
|
|
||||||
static setOptions({
|
static setOptions({
|
||||||
canvasMaxAreaInBytes = -1,
|
canvasMaxAreaInBytes = -1,
|
||||||
isChrome = false,
|
|
||||||
isImageDecoderSupported = false,
|
isImageDecoderSupported = false,
|
||||||
}) {
|
}) {
|
||||||
if (!this._hasMaxArea) {
|
if (!this._hasMaxArea) {
|
||||||
// Divide by 4 to have the value in pixels.
|
// Divide by 4 to have the value in pixels.
|
||||||
this.MAX_AREA = canvasMaxAreaInBytes >> 2;
|
this.MAX_AREA = canvasMaxAreaInBytes >> 2;
|
||||||
}
|
}
|
||||||
// TODO: remove the isChrome, once Chrome doesn't crash anymore with
|
this.#isImageDecoderSupported = isImageDecoderSupported;
|
||||||
// issue6741.pdf.
|
|
||||||
// https://issues.chromium.org/issues/374807001.
|
|
||||||
this.#isImageDecoderSupported = isImageDecoderSupported && !isChrome;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static _areGoodDims(width, height) {
|
static _areGoodDims(width, height) {
|
||||||
|
|||||||
@ -181,9 +181,17 @@ const DefaultStandardFontDataFactory =
|
|||||||
* `ImageDecoder` in the worker. Primarily used to improve performance of
|
* `ImageDecoder` in the worker. Primarily used to improve performance of
|
||||||
* image conversion/rendering.
|
* image conversion/rendering.
|
||||||
* The default value is `true` in web environments and `false` in Node.js.
|
* The default value is `true` in web environments and `false` in Node.js.
|
||||||
* @property {boolean} [isChrome] - Determines if we can use bmp ImageDecoder.
|
*
|
||||||
* NOTE: Temporary option until [https://issues.chromium.org/issues/374807001]
|
* NOTE: Also temporarily disabled in Chromium browsers, until we no longer
|
||||||
* is fixed.
|
* support the affected browser versions, because of various bugs:
|
||||||
|
*
|
||||||
|
* - Crashes when using the BMP decoder with huge images, e.g. issue6741.pdf;
|
||||||
|
* see https://issues.chromium.org/issues/374807001
|
||||||
|
*
|
||||||
|
* - Broken images when using the JPEG decoder with images that have custom
|
||||||
|
* colour profiles, e.g. GitHub discussion 19030;
|
||||||
|
* see https://issues.chromium.org/issues/378869810
|
||||||
|
*
|
||||||
* @property {number} [canvasMaxAreaInBytes] - The integer value is used to
|
* @property {number} [canvasMaxAreaInBytes] - The integer value is used to
|
||||||
* know when an image must be resized (uses `OffscreenCanvas` in the worker).
|
* know when an image must be resized (uses `OffscreenCanvas` in the worker).
|
||||||
* If it's -1 then a possibly slow algorithm is used to guess the max value.
|
* If it's -1 then a possibly slow algorithm is used to guess the max value.
|
||||||
@ -289,16 +297,15 @@ function getDocument(src = {}) {
|
|||||||
? src.isOffscreenCanvasSupported
|
? src.isOffscreenCanvasSupported
|
||||||
: !isNodeJS;
|
: !isNodeJS;
|
||||||
const isImageDecoderSupported =
|
const isImageDecoderSupported =
|
||||||
|
// eslint-disable-next-line no-nested-ternary
|
||||||
typeof src.isImageDecoderSupported === "boolean"
|
typeof src.isImageDecoderSupported === "boolean"
|
||||||
? src.isImageDecoderSupported
|
? src.isImageDecoderSupported
|
||||||
: !isNodeJS;
|
: // eslint-disable-next-line no-nested-ternary
|
||||||
const isChrome =
|
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
|
||||||
typeof src.isChrome === "boolean"
|
? true
|
||||||
? src.isChrome
|
: typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")
|
||||||
: (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
|
? false
|
||||||
!FeatureTest.platform.isFirefox &&
|
: !isNodeJS && (FeatureTest.platform.isFirefox || !globalThis.chrome);
|
||||||
typeof window !== "undefined" &&
|
|
||||||
!!window?.chrome;
|
|
||||||
const canvasMaxAreaInBytes = Number.isInteger(src.canvasMaxAreaInBytes)
|
const canvasMaxAreaInBytes = Number.isInteger(src.canvasMaxAreaInBytes)
|
||||||
? src.canvasMaxAreaInBytes
|
? src.canvasMaxAreaInBytes
|
||||||
: -1;
|
: -1;
|
||||||
@ -404,7 +411,6 @@ function getDocument(src = {}) {
|
|||||||
isEvalSupported,
|
isEvalSupported,
|
||||||
isOffscreenCanvasSupported,
|
isOffscreenCanvasSupported,
|
||||||
isImageDecoderSupported,
|
isImageDecoderSupported,
|
||||||
isChrome,
|
|
||||||
canvasMaxAreaInBytes,
|
canvasMaxAreaInBytes,
|
||||||
fontExtraProperties,
|
fontExtraProperties,
|
||||||
useSystemFonts,
|
useSystemFonts,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user