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

Fix DOMFilterFactory.#createUrl in MOZCENTRAL builds (18417 PR follow-up) #18430

Merged
merged 1 commit into from
Jul 15, 2024

Conversation

Snuffleupagus
Copy link
Collaborator

Somehow I managed to mess up the URL creation relevant to e.g. MOZCENTRAL builds, which is breaking the pending PDF.js update in mozilla-central; sorry about that!

Copy link
Contributor

@timvandermeij timvandermeij 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 passing tests.

@timvandermeij
Copy link
Contributor

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/feb921e4f5ea90c/output.txt

Copy link
Contributor

@calixteman calixteman left a comment

Choose a reason for hiding this comment

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

Arrff... I missed that too.
Thank you.

@calixteman
Copy link
Contributor

This test should have failed:

pdf.js/test/test_manifest.json

Lines 8777 to 8782 in 2d25437

"id": "issue16114",
"file": "pdfs/issue16114.pdf",
"md5": "c04827ea33692e0f94a5e51716d9aa2e",
"rounds": 1,
"link": true,
"type": "eq"
.
@Snuffleupagus do you know why it didn't ?

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/feb921e4f5ea90c/output.txt

Total script time: 29.91 mins

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

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

@Snuffleupagus
Copy link
Collaborator Author

do you know why it didn't ?

Yes, because of the pre-processor; see

#createUrl(id) {
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (this.#baseUrl === undefined) {
const url = this.#document.URL;
if (url === this.#document.baseURI) {
// No `<base>`-element present, hence a relative URL should work.
this.#baseUrl = "";
} else if (isDataScheme(url)) {
warn('#createUrl: ignore "data:"-URL for performance reasons.');
this.#baseUrl = "";
} else {
this.#baseUrl = url.split("#", 1)[0];
}
}
return `url(${this.#baseUrl}#${id})`;
}
return `url(${id})`;
}

The idea was to ensure that we actually test the GENERIC code in the PDF.js test-suite, since the Firefox code-path is covered by tests in mozilla-central. Perhaps we should just use the #baseUrl feature regardless of build-target here?

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

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

Total script time: 44.15 mins

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

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

@Snuffleupagus
Copy link
Collaborator Author

@calixteman Would you prefer the following diff instead, where we'd always check if a baseUrl is needed?

diff --git a/src/display/display_utils.js b/src/display/display_utils.js
index 30964c9ab..9d4a41723 100644
--- a/src/display/display_utils.js
+++ b/src/display/display_utils.js
@@ -124,22 +124,19 @@ class DOMFilterFactory extends BaseFilterFactory {
   }
 
   #createUrl(id) {
-    if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
-      if (this.#baseUrl === undefined) {
-        const url = this.#document.URL;
-        if (url === this.#document.baseURI) {
-          // No `<base>`-element present, hence a relative URL should work.
-          this.#baseUrl = "";
-        } else if (isDataScheme(url)) {
-          warn('#createUrl: ignore "data:"-URL for performance reasons.');
-          this.#baseUrl = "";
-        } else {
-          this.#baseUrl = url.split("#", 1)[0];
-        }
+    if (this.#baseUrl === undefined) {
+      const url = this.#document.URL;
+      if (url === this.#document.baseURI) {
+        // No `<base>`-element present, hence a relative URL should work.
+        this.#baseUrl = "";
+      } else if (isDataScheme(url)) {
+        warn('#createUrl: ignore "data:"-URL for performance reasons.');
+        this.#baseUrl = "";
+      } else {
+        this.#baseUrl = url.split("#", 1)[0];
       }
-      return `url(${this.#baseUrl}#${id})`;
     }
-    return `url(${id})`;
+    return `url(${this.#baseUrl}#${id})`;
   }
 
   addFilter(maps) {

@calixteman
Copy link
Contributor

@calixteman Would you prefer the following diff instead, where we'd always check if a baseUrl is needed?

diff --git a/src/display/display_utils.js b/src/display/display_utils.js
index 30964c9ab..9d4a41723 100644
--- a/src/display/display_utils.js
+++ b/src/display/display_utils.js
@@ -124,22 +124,19 @@ class DOMFilterFactory extends BaseFilterFactory {
   }
 
   #createUrl(id) {
-    if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
-      if (this.#baseUrl === undefined) {
-        const url = this.#document.URL;
-        if (url === this.#document.baseURI) {
-          // No `<base>`-element present, hence a relative URL should work.
-          this.#baseUrl = "";
-        } else if (isDataScheme(url)) {
-          warn('#createUrl: ignore "data:"-URL for performance reasons.');
-          this.#baseUrl = "";
-        } else {
-          this.#baseUrl = url.split("#", 1)[0];
-        }
+    if (this.#baseUrl === undefined) {
+      const url = this.#document.URL;
+      if (url === this.#document.baseURI) {
+        // No `<base>`-element present, hence a relative URL should work.
+        this.#baseUrl = "";
+      } else if (isDataScheme(url)) {
+        warn('#createUrl: ignore "data:"-URL for performance reasons.');
+        this.#baseUrl = "";
+      } else {
+        this.#baseUrl = url.split("#", 1)[0];
       }
-      return `url(${this.#baseUrl}#${id})`;
     }
-    return `url(${id})`;
+    return `url(${this.#baseUrl}#${id})`;
   }
 
   addFilter(maps) {

Let's do that: I think it's slightly simpler and it shouldn't add any specific penalty.

@calixteman
Copy link
Contributor

@Snuffleupagus, could you merge this PR asap, and then I'll make a new release.

…ow-up)

Somehow I managed to mess up the URL creation relevant to e.g. MOZCENTRAL builds, which is breaking the pending PDF.js update in mozilla-central; sorry about that!

To avoid future issues, we'll now always check if absolute filter-URLs are necessary regardless of the build-target.
@Snuffleupagus
Copy link
Collaborator Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/405f05fa597a2a8/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/405f05fa597a2a8/output.txt

Total script time: 29.93 mins

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

Image differences available at: http://54.241.84.105:8877/405f05fa597a2a8/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/a3981fdab0cd3a1/output.txt

Total script time: 44.35 mins

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

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

@Snuffleupagus Snuffleupagus merged commit f9e3b6b into mozilla:master Jul 15, 2024
9 checks passed
@Snuffleupagus Snuffleupagus deleted the pr-18417-followup branch July 15, 2024 13:05
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