Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a BMP decoder when resizing an image #18918

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

calixteman
Copy link
Contributor

The image decoding won't block the main thread any more.
For now, it isn't enabled for Chrome because issue6741.pdf leads to a crash.

The image decoding won't block the main thread any more.
For now, it isn't enabled for Chrome because issue6741.pdf leads to a crash.
@calixteman
Copy link
Contributor Author

/botio browsertest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 0

Live output at: http://54.241.84.105:8877/89dce42e9880aed/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_browsertest from @calixteman received. Current queue size: 0

Live output at: http://54.193.163.58:8877/623d99422ac60d8/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/89dce42e9880aed/output.txt

Total script time: 21.25 mins

  • Regression tests: FAILED
  errors: 120
  different ref/snapshot: 16
  different first/second rendering: 2

Image differences available at: http://54.241.84.105:8877/89dce42e9880aed/reftest-analyzer.html#web=eq.log

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/623d99422ac60d8/output.txt

Total script time: 29.31 mins

  • Regression tests: FAILED
  different ref/snapshot: 2396

Image differences available at: http://54.193.163.58:8877/623d99422ac60d8/reftest-analyzer.html#web=eq.log

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have benchmarking results that show (clear) improvements with this patch?

Have you reported the Chrome-crash to the browser developers?

return shadow(this, "platform", {
isChrome: !isFirefox && !!window.chrome,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this isn't safe, since code in src/shared/ will run on both the main- and worker-threads (and in Node.js) so you cannot access window here.

Can we please just revert the changes in this file (I'll make a few other suggestions)?

@@ -1045,6 +1045,7 @@ const PDFViewerApplication = {
const loadingTask = getDocument({
...apiParams,
...args,
isChrome: FeatureTest.platform.isChrome,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this.

Suggested change
isChrome: FeatureTest.platform.isChrome,

@@ -177,6 +177,7 @@ const DefaultStandardFontDataFactory =
* `OffscreenCanvas` in the worker. Primarily used to improve performance of
* image conversion/rendering.
* The default value is `true` in web environments and `false` in Node.js.
* @property {boolean} [isChrome] - Determines if we can use bmp ImageDecoder.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @property {boolean} [isChrome] - Determines if we can use bmp ImageDecoder.
* @property {boolean} [isChrome] - Determines if we can use bmp ImageDecoder.
* NOTE: Temporary option until [link to Chromium bug report] is fixed.

@@ -281,6 +282,7 @@ function getDocument(src = {}) {
typeof src.isOffscreenCanvasSupported === "boolean"
? src.isOffscreenCanvasSupported
: !isNodeJS;
const isChrome = src.isChrome === true;
Copy link
Collaborator

@Snuffleupagus Snuffleupagus Oct 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid issues, and to support this properly when running tests, can we please change it as follows?

Suggested change
const isChrome = src.isChrome === true;
const isChrome =
typeof src.isChrome === "boolean"
? src.isChrome
: (typeof PDFJSDev === "undefined" || !PDFJSDev.test("MOZCENTRAL")) &&
!FeatureTest.platform.isFirefox &&
typeof window !== "undefined" &&
!!window?.chrome;

let decoder, imagePromise;

// TODO: remove the isChrome, once Chrome isn't crashing anymore with
// isssue6741.pdf.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// isssue6741.pdf.
// issue6741.pdf.

// TODO: remove the isChrome, once Chrome isn't crashing anymore with
// isssue6741.pdf.
if (
(typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I don't believe that enabling this unconditionally in Firefox is safe, since this can be disabled with a preference and that preference is only enabled by default in Nightly: https://searchfox.org/mozilla-central/rev/ec342a3d481d9ac3324d1041e05eefa6b61392d2/modules/libpref/init/StaticPrefList.yaml#3241-3245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants