Skip to content

Conversation

nicolo-ribaudo
Copy link
Contributor

Store ops bboxes in a linear Uint8Array

This PR changes the way we store bounding boxes so that they use less memory and can be more easily shared across threads in the future.

Instead of storing the bounding box and list of dependencies for each operation that renders something, we now only store the bounding box of every operation and no dependencies list. The bounding box of each operation covers the bounding box of all the operations affected by it that render something. For example, the bounding box of a setFont operation will be the bounding box of all the showText operations that use that font.

This affects the debugging experience in pdfBug, since now the bounding box of an operation may be larger than what it renders itself. To help with this, now when hovering on an operation we also highlight (in red) all its dependents. We highlight with white stripes operations that do not affect any part of the page (i.e. with an empty bbox).

To save memory, we now save bounding box x/y coordinates as uint8 rather than float64. This effectively gives us a 256x256 uniform grid that covers the page, which is high enough resolution for the usecase.

Follow up to #19043.

Due to the more coarse bounding boxes, some tests that previously had a 1-pixel difference on the edge of the partial render now match exactly. We'll need to re-generate the reference images for them.

@nicolo-ribaudo
Copy link
Contributor Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 0

Live output at: http://54.241.84.105:8877/7e4be60b1d2e9cf/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 0

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

@nicolo-ribaudo nicolo-ribaudo marked this pull request as draft August 27, 2025 14:08
@nicolo-ribaudo
Copy link
Contributor Author

issue16127-partial is an actual failure.

@nicolo-ribaudo
Copy link
Contributor Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 1

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 1

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

@nicolo-ribaudo nicolo-ribaudo marked this pull request as ready for review August 27, 2025 14:10
@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/7e4be60b1d2e9cf/output.txt

Total script time: 37.21 mins

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

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

Total script time: 73.01 mins

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

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

Total script time: 37.50 mins

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

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

Total script time: 72.64 mins

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

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

@nicolo-ribaudo nicolo-ribaudo force-pushed the bboxes-typedarray branch 3 times, most recently from 62931e4 to 7205c79 Compare August 27, 2025 19:34
@nicolo-ribaudo
Copy link
Contributor Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 0

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 0

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

@nicolo-ribaudo
Copy link
Contributor Author

/botio preivew

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Invalid

Command not implemented: preivew.

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Invalid

Command not implemented: preivew.

@nicolo-ribaudo
Copy link
Contributor Author

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @nicolo-ribaudo received. Current queue size: 1

Live output at: http://54.241.84.105:8877/1e9f58f26ca2aa9/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

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

Total script time: 38.02 mins

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/1e9f58f26ca2aa9/output.txt

Total script time: 0.94 mins

Published

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

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

Total script time: 75.76 mins

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

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

@nicolo-ribaudo
Copy link
Contributor Author

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @nicolo-ribaudo received. Current queue size: 0

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

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

Total script time: 0.94 mins

Published

@nicolo-ribaudo
Copy link
Contributor Author

The preview URL doesn't seem to work, but this should be ready.

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.

LGTM. Thank you.

This PR changes the way we store bounding boxes so that they use less
memory and can be more easily shared across threads in the future.

Instead of storing the bounding box and list of dependencies for each
operation that renders _something_, we now only store the bounding box
of _every_ operation and no dependencies list. The bounding box of
each operation covers the bounding box of all the operations affected
by it that render something. For example, the bounding box of a
`setFont` operation will be the bounding box of all the `showText`
operations that use that font.

This affects the debugging experience in pdfBug, since now the bounding
box of an operation may be larger than what it renders itself. To help
with this, now when hovering on an operation we also highlight (in red)
all its dependents. We highlight with white stripes operations that do
not affect any part of the page (i.e. with an empty bbox).

To save memory, we now save bounding box x/y coordinates as uint8
rather than float64. This effectively gives us a 256x256 uniform grid
that covers the page, which is high enough resolution for the usecase.
@nicolo-ribaudo
Copy link
Contributor Author

/botio test

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 0

Live output at: http://54.193.163.58:8877/40c9d727050f303/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_test from @nicolo-ribaudo received. Current queue size: 0

Live output at: http://54.241.84.105:8877/7da6f2a47a8ffb0/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

Full output at http://54.241.84.105:8877/7da6f2a47a8ffb0/output.txt

Total script time: 37.37 mins

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

Image differences available at: http://54.241.84.105:8877/7da6f2a47a8ffb0/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/40c9d727050f303/output.txt

Total script time: 77.21 mins

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

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

@nicolo-ribaudo
Copy link
Contributor Author

Snapshot differences look correct

@calixteman calixteman merged commit beb5f5c into mozilla:master Sep 12, 2025
8 of 9 checks passed
@calixteman
Copy link
Contributor

/botio makeref

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

Live output at: http://54.241.84.105:8877/6b6979be7e630b2/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/6b6979be7e630b2/output.txt

Total script time: 17.95 mins

  • Make references: Passed
  • Check references: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

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

Total script time: 31.66 mins

  • Make references: Passed
  • Check references: Passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants