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

Merged
merged 1 commit into from
Oct 28, 2024

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.

@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?

src/shared/util.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
src/display/api.js Show resolved Hide resolved
src/display/api.js Outdated Show resolved Hide resolved
src/core/image_resizer.js Outdated Show resolved Hide resolved
src/core/image_resizer.js Outdated Show resolved Hide resolved
@calixteman
Copy link
Contributor Author

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

With the issue16263.pdf, I made 15 measures in using performance.now() and getting the image from the bmp buffer takes:

  • ~2.4s (stddev ~0.6s) with ImageDecoder
  • ~3.3s (stddev ~1.1s) with createImageBitmap

with a debug build of Firefox on Windows 11.
As far as I know, it shouldn't make that much difference in term of decoding because at the end the same code with the same data is called on the C++ side, but with ImageDecoder we can avoid a copy of the buffer thanks to the transfer parameter. The main difference is that the decoding happens in an other thread than the main content thread. I think that decoding on the main thread explains the higher variability (see the standard deviation in the createImageBitmap case).
From my point of view the main interest of this patch is to not have the decoding blocking the main thread and as a side effect if we can win few tens of millis it isn't that bad either.

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

Yep we reached the Chrome dev in charge of that stuff yesterday and they filed a bug for the crash:
https://issues.chromium.org/issues/374807001

src/shared/util.js Outdated Show resolved Hide resolved
src/core/image_resizer.js Outdated Show resolved Hide resolved
src/core/image_resizer.js Outdated Show resolved Hide resolved
@calixteman
Copy link
Contributor Author

The bug is fixed in Chrome, I checked in Canary and everything is working correctly.
/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/575fa92d11d2020/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/b3bb5d9306cf601/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/575fa92d11d2020/output.txt

Total script time: 30.74 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 14
  different first/second rendering: 1

Image differences available at: http://54.241.84.105:8877/575fa92d11d2020/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/b3bb5d9306cf601/output.txt

Total script time: 51.25 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: FAILED
  different ref/snapshot: 1

Image differences available at: http://54.193.163.58:8877/b3bb5d9306cf601/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.

r=me, with a couple of suggestions to further reduce the impact on the Firefox PDF Viewer; thank you.

src/core/evaluator.js Outdated Show resolved Hide resolved
src/core/image_resizer.js Outdated Show resolved Hide resolved
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 test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/974893ad4a7fb38/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/05f37cfd1f015e9/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/974893ad4a7fb38/output.txt

Total script time: 30.77 mins

  • Unit tests: Passed
  • Integration Tests: Passed
  • Regression tests: FAILED
  different ref/snapshot: 11
  different first/second rendering: 1

Image differences available at: http://54.241.84.105:8877/974893ad4a7fb38/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/05f37cfd1f015e9/output.txt

Total script time: 51.46 mins

  • Unit tests: Passed
  • Integration Tests: FAILED
  • Regression tests: Passed

@calixteman calixteman merged commit 9108848 into mozilla:master Oct 28, 2024
10 checks passed
@calixteman calixteman deleted the bmp_decoder branch October 28, 2024 15:30
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