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

Add an option to enable/disable hardware acceleration (bug 1902012) #18238

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

calixteman
Copy link
Contributor

No description provided.

@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/9f3ddb12d4070bc/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/caa82771b7db49d/output.txt

src/display/api.js Outdated Show resolved Hide resolved
src/display/base_factory.js Outdated Show resolved Hide resolved
web/app.js Outdated Show resolved Hide resolved
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/9f3ddb12d4070bc/output.txt

Total script time: 28.87 mins

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

Image differences available at: http://54.241.84.105:8877/9f3ddb12d4070bc/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/caa82771b7db49d/output.txt

Total script time: 41.61 mins

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

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

@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/95003cd5491e9e1/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/c03d7a10b723af1/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/95003cd5491e9e1/output.txt

Total script time: 29.04 mins

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

Image differences available at: http://54.241.84.105:8877/95003cd5491e9e1/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 the final comments addressed; thank you!

src/display/api.js Outdated Show resolved Hide resolved
web/app_options.js Outdated Show resolved Hide resolved
web/pdf_page_view.js Outdated Show resolved Hide resolved
src/display/node_utils.js Outdated Show resolved Hide resolved
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/c03d7a10b723af1/output.txt

Total script time: 44.19 mins

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

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

@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/26467fb15f49b35/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/e164b4315fc63ec/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/26467fb15f49b35/output.txt

Total script time: 28.62 mins

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

Image differences available at: http://54.241.84.105:8877/26467fb15f49b35/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/e164b4315fc63ec/output.txt

Total script time: 43.71 mins

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

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

@calixteman calixteman merged commit f8ffc5b into mozilla:master Jun 12, 2024
9 checks passed
@calixteman calixteman deleted the disable_gpu branch June 12, 2024 17:27
@qwer1304
Copy link

Why isn't the option exposed in Chrome's options?
("title": "Enable HW acceleration" is missing below line 48 in extensions/chromium/preferences_schema.json)

@Rob--W
Copy link
Member

Rob--W commented Jun 15, 2024

While disabling HWA unconditionally will certainly fix some issues associated with https://bugzilla.mozilla.org/show_bug.cgi?id=1902012, I wonder whether doing this unconditionally by default is the correct approach to take.

Do we have any data that shows that turning off HWA unconditionally is going to have a larger positive impact than the performance loss on systems where HWA outperforms software rendering?

Browsers usually have hardware blocklists to selectively disable HWA on systems that are known to have issues with HWA. Additionally, users can override the browser defaults, chrome://flags/#disable-accelerated-2d-canvas in Chrome, or gfx.canvas.accelerated=false in about:config in Firefox.

This patch does not only add an option to disable HWA, it already disables HWA in situations where the PDF.js code is expected to read back data, by specifying willReadFrequently:true unconditionally.

@calixteman
Copy link
Contributor Author

@Rob--W, I wasn't so happy to disable hwa for the exact reasons you gave (and tbh I was pretty reluctant).
We've now some performance tests in m-c and I hope we'll have some numbers soon.
An other thing we could do is to create a Nimbus experiment to try measure if there are significant difference when rendering the first page for the different cohorts.

@Rob--W
Copy link
Member

Rob--W commented Jun 15, 2024

If there are doubts about disabling unconditionally, could we change the default to true (so that the use of HWA is controlled by the browser/user)? The mere existence of the setting now enables others to opt out if they want to deploy PDF.js in an environment where HWA is an issue.

PDF.js + HWA has been out in the wild for many years at this point, whereas HWA off is a new change here. I think that it would be lower risk to default to true (since it is the same as before), and then experiment with turning it off in cohorts. If that shows a noticeable performance difference, then the default can change.

@marco-c
Copy link
Contributor

marco-c commented Jun 15, 2024

IIRC canvas acceleration has only been available recently in Firefox, so effectively it's only a short time HWA has been really enabled in Firefox.
I think we can quickly estimate the effects by running the perf tests and comparing, this will give us a good initial idea.

@Rob--W
Copy link
Member

Rob--W commented Jun 15, 2024

It's indeed relatively new, but not trivial either (1.5 years).

HWA canvas has been enabled on Linux+macOS since Firefox 110 (https://bugzilla.mozilla.org/show_bug.cgi?id=1806058), on Android since Firefox 113 (https://bugzilla.mozilla.org/show_bug.cgi?id=1825182). Interestingly, canvas HWA seems not enabled on Windows: https://searchfox.org/mozilla-central/rev/94f839e924ba6c69f3e0d062d4c6cc4fee7cad5b/modules/libpref/init/StaticPrefList.yaml#5706-5715

In Chrome, HWA canvas has been around for 12 years, judging by the announcement at https://developer.chrome.com/blog/taking-advantage-of-gpu-acceleration-in-the-2d-canvas/

If there is a desire to turn off HWA by default, I'd like it to be enabled by default in the Chrome extension (I can submit a patch), unless there is data that shows that HWA off-by-default offers a better experience.

I think we can quickly estimate the effects by running the perf tests and comparing, this will give us a good initial idea.

Is this only in Firefox, or does it also cover other browser engines such as Chromium?

@qwer1304
Copy link

qwer1304 commented Jun 16, 2024

At least I can tell you that I've been having issues when HWA was turned OFF in pdf.js running in Chrome as listed in issue 18242. That's why I asked about making it a user controlled option in Chrome. After enabling it, the weird issues have gone away (for the meantime).
It's worth mentioning that it seems that the pdf.js option is NOT completely equivalent to the Chrome's flag option (chrome://flags/#disable-accelerated-2d-canvas), since I've been having issues even with the HWA disabled in Chrome whilst it was disabled in pdf.js. Only after enabling HWA in pdf.js did the issues gone away.

shivaprsd added a commit to shivaprsd/doq that referenced this pull request Jul 25, 2024
This commit introduces a new option `softwareRender` to allow users to
manually configure disabling GPU instead of guessing the browser. This
cleans up the temporary fix introduced in the previous commit, which we
have decided to keep as the PDF.js team has addressed the issue and has
chosen to do the same via a preference (mozilla/pdf.js#18238 on GitHub).
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.

PDF freezes when opened with Firefox with HW Acceleration ON despite very powerful PC specs
6 participants