Closed Bug 1821408 Opened 1 year ago Closed 1 year ago

SVG filters aren't working correctly in the pdf builtin viewer

Categories

(Firefox :: PDF Viewer, defect)

defect

Tracking

()

VERIFIED FIXED
113 Branch
Tracking Status
firefox-esr102 --- unaffected
firefox110 --- unaffected
firefox111 --- unaffected
firefox112 --- verified
firefox113 --- verified

People

(Reporter: calixte, Assigned: calixte)

References

(Regression)

Details

(Keywords: regression)

Attachments

(4 files, 1 obsolete file)

Attached file issue6931_reduced.pdf

In nightly, the image on the right isn't rendered correctly because the SVG filters aren't applied.
If you open the pdf in https://mozilla.github.io/pdf.js/web/viewer.html then it works as expected.

The code we've in both viewers is almost exactly the same.
The code to create the svg node and the filter is:
https://github.com/mozilla/pdf.js/blob/a0ef5a4ae1ff7a5ed225d1ecac78695f10b3348b/src/display/display_utils.js#L68-L160

then we return url(#transfer_map_0) which is used here:
https://github.com/mozilla/pdf.js/blob/a0ef5a4ae1ff7a5ed225d1ecac78695f10b3348b/src/display/canvas.js#L3056-L3058

I added a console.log here:
https://searchfox.org/mozilla-central/rev/cd2121e7d83af1b421c95e8c923db70e692dab5f/toolkit/components/pdfjs/content/build/pdf.js#6787

to check that the filter is ok and it's.
So it looks like the filter is not applied or found.

:lslazman, would you have an idea on what's wrong here ?

Flags: needinfo?(lsalzman)

Set release status flags based on info from the regressing bug 1819982

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

:lslazman, would you have an idea on what's wrong here ?

Offhand, not exactly. Can you please check with Mozregression what change might have caused the issue?

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

I think I found what the issue is:

I'll try to write a patch tomorrow.

Flags: needinfo?(cdenizet)

PDF.js is now using some SVG filters to implement the transfer maps stuff.
Those filters are used in using an url with an id but because of a mismatch
between the document URI and the URI used to find the id, the SVG element
wasn't found.
Consequently, this patch just add an exception when the id is searched for
a pdf document.

Assignee: nobody → cdenizet
Status: NEW → ASSIGNED
Attachment #9322319 - Attachment description: Bug 1821408 - Allow pdf.js to use SVG filters using ids r=emilio → Bug 1821408 - Add a test for testing SVG filters in pdf.js r=#pdfjs-reviewers

Set release status flags based on info from the regressing bug 1819982

Attachment #9322364 - Attachment is obsolete: true

:calixte will the pdf.js version be updated and uplifted to 112?

Flags: needinfo?(cdenizet)
Pushed by cdenizet@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/163d0d505694
Add a test for testing SVG filters in pdf.js r=pdfjs-reviewers,emilio,marco

Backed out for causing failures in browser_pdfjs_filters.js.

  • Backout link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | toolkit/components/pdfjs/test/browser_pdfjs_filters.js | Not enough red pixels: only 5521 red pixels! - false == true - {"filename":"chrome://mochitests/content/browser/toolkit/components/pdfjs/test/browser_pdfjs_filters.js","name":"test/<","sourceId":675,"lineNumber":73,"columnNumber":14,"sourceLine":"","asyncCause":null,"asyncCaller":{"filename":"resource://testing-common/BrowserTestUtils.sys.mjs","name":"withNewTab","s
Pushed by cdenizet@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/199b5933bc03
Add a test for testing SVG filters in pdf.js r=pdfjs-reviewers,emilio,marco

Comment on attachment 9324363 [details]
Bug 1821408 - Remove <base> tag from the pdf viewer in order to have SVG filters working correctly r=#pdfjs-reviewers

Beta/Release Uplift Approval Request

  • User impact if declined: Some pdfs could have some wrong colors because some filters won't be applied and it'll be a regression.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: Yes
  • If yes, steps to reproduce: Open the attachment and observe a red "heart".
    It can be tested with the pdf in https://github.com/mozilla/pdf.js/issues/16114 (the spider must be in blue/green shades).
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): It's a small and self contained change.
  • String changes made/needed:
  • Is Android affected?: Yes
Flags: needinfo?(cdenizet)
Attachment #9324363 - Flags: approval-mozilla-beta?
Attachment #9322319 - Flags: approval-mozilla-beta?
Flags: qe-verify+
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
QA Whiteboard: [qa-triaged]

I have reproduced this issue using Firefox 112.0a1 (2023.03.09) on Windows 10 x64.
I can confirm this issue is fixed, I verified using Firefox 113.0a1 on Windows 10, Ubuntu 22 and on macOS 12, both of pdf links works as expected, in
the attachment the "heart" is red and the spider is blue/green shades.

Flags: qe-verify+
Severity: -- → S3

Comment on attachment 9322319 [details]
Bug 1821408 - Add a test for testing SVG filters in pdf.js r=#pdfjs-reviewers

Approved for 112.0b7

Attachment #9322319 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Attachment #9324363 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify+

I can confirm this issue is fixed, I verified using Firefox 112.0b7 on Windows 10, Ubuntu 22 and on macOS 10.15, both of pdf links works as expected, in
the attachment the "heart" is red and the spider is blue/green shades.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Regressions: 1830645
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: