Open Bug 1891808 Opened 5 months ago Updated 2 months ago

Opening specific PDF freezes Firefox for 10s, if hardware acceleration is enabled

Categories

(Core :: Graphics: Canvas2D, defect)

Firefox 127
Unspecified
Linux
defect

Tracking

()

REOPENED

People

(Reporter: linuxhippy, Unassigned)

References

Details

Attachments

(2 files)

Attached file ea211.pdf

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0

Steps to reproduce:

opened https://static.nhtsa.gov/odi/tsbs/2015/MC-10124696-9999.pdf

Actual results:

Firefox froze during loading for 10s

Expected results:

firefox should not freeze during loading

The Bugbug bot thinks this bug should belong to the 'Firefox::PDF Viewer' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → PDF Viewer

Could you install the Firefox profiler and get a profile when loading the pdf ?
I cannot reproduce your issue.

The severity field is not set for this bug.
:calixte, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(cdenizet)

I profiled the rendering of the first 10 pages and I don't see anything on Windows 11.
:Clemens, if you can still reproduce this issue, please provide us a performance profile and reopen this bug.

Status: UNCONFIRMED → RESOLVED
Closed: 5 months ago
Flags: needinfo?(cdenizet)
Resolution: --- → INCOMPLETE

Maybe you should try it on a linux box?
But if you prefer, you can leave it in resolved state too - it won't make any difference.

Firefox profile with pdf.js from github:
https://share.firefox.dev/4a1OVpc

The first page appears, but afterwards firefox doesn't respond 10 seconds on input - even the loading spinner gets stuck.

Attached image sysprof.png

profile recorded with sysprof

Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INCOMPLETE → ---

The severity field is not set for this bug.
:calixte, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(cdenizet)

The profile shows that we spend too much time in drawing the gradient.
:jrmuizel, could you have a look please ?

Flags: needinfo?(cdenizet) → needinfo?(jmuizelaar)

Redirecting NI to Lee.

As a short term fix it might be worth considering having pdf.js use willReadFrequently to avoid using GPU canvas.

Depends on: 1895168
Flags: needinfo?(jmuizelaar) → needinfo?(lsalzman)

As a short term fix it might be worth considering having pdf.js use willReadFrequently to avoid using GPU canvas.

Yes I think it's a good idea.
I'll add a pref in order to use willReadFrequently:
If the pref is:

  • true (default in nightly) then willReadFrequently is false
  • false (default in beta/release) then willReadFrequently is true
    I think it makes sense to have willReadFrequently set to false in nightly in order to be able to catch potential regressions.

(In reply to Calixte Denizet (:calixte) from comment #10)

As a short term fix it might be worth considering having pdf.js use willReadFrequently to avoid using GPU canvas.

Yes I think it's a good idea.
I'll add a pref in order to use willReadFrequently:
If the pref is:

  • true (default in nightly) then willReadFrequently is false
  • false (default in beta/release) then willReadFrequently is true
    I think it makes sense to have willReadFrequently set to false in nightly in order to be able to catch potential regressions.

As we discussed in the team meeting today, we should have willReadFrequently true in Nightly too because we need to catch regressions in the configuration we actually ship to users.
If feasible and if it is of interest to the gfx team, we could run the perf tests both with willReadFrequently set to true and with willReadFrequently set to false.

So if PDFJs is reading back frequntly from the Canvas - isn't Canvas the wrong abstraction for rendering PDFs?
Wouldn't it make more sense to open a WebGL context and use that for rendering (which in the end a gpu accelerated canvas will do more or less, too - just without the WebGL API abstraction) and perform the operations required using shaders instead of using an arbitrary limited API interface (Canvas) which causes because of its intentional simplicity many software-fallbacks / readbacks?

OS: Unspecified → Linux

(In reply to Jeff Muizelaar [:jrmuizel] from comment #9)

Redirecting NI to Lee.

As a short term fix it might be worth considering having pdf.js use willReadFrequently to avoid using GPU canvas.

I guess this would also help with bug 1895499.

See Also: → 1895499
See Also: → 1901708
Depends on: 1902012
Component: PDF Viewer → Graphics: Canvas2D
Product: Firefox → Core
Summary: Opening specific PDF freezes Firefox for 10s → Opening specific PDF freezes Firefox for 10s, if hardware acceleration is enabled
Flags: needinfo?(lsalzman)

The severity field is not set for this bug.
:lsalzman, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(lsalzman)
Severity: -- → S3
Flags: needinfo?(lsalzman)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: