Add logic to track rendering area of various PDF ops#19043
Add logic to track rendering area of various PDF ops#19043calixteman merged 1 commit intomozilla:masterfrom
Conversation
2475b16 to
5a6a877
Compare
49c4689 to
eac70e4
Compare
|
master...nicolo-ribaudo:pdf.js:draw-page-portion-optimized is a branch merging this PR together with #19128. In the video below you can see that it first renders in the background a low-resolution image "the old way" taking 12 seconds, and then it renders the "detail view" on top taking only 1.4 seconds and only running one fifth of the PDF operations :) Screen.Recording.2024-12-17.at.18.10.30.mp4Still keeping this as draft because there are significant bugs (in the PDF I'm using for testing, it often skips rendering some pieces of text even if they are visible on screen, or it renders some paths with the wrong color), but it's nice to see some progress. |
|
Very good progress on this! This is a feature that the community is waiting a long time for. Can't wait to see more progress on this. |
4cd3d42 to
e24c57c
Compare
e24c57c to
8184a06
Compare
8184a06 to
cad8d31
Compare
|
Update!
This video shows how we are skipping some ops while rendering the detail view as we scroll around the page :) Screen.Recording.2025-06-02.at.16.00.49.movThe main missing task is that I have to properly hook this logic up to the reftests, maybe rendering a fraction of the page with the logic and checking that it matches the same fraction of the page with the unoptimized rendering. Once this is done, I can go through the failing tests one by one and add the missing tracking. |
c294316 to
740b221
Compare
From: Bot.io (Windows)ReceivedCommand cmd_test from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.193.163.58:8877/b5954f4701f62b6/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/96c4987519a6873/output.txt Total script time: 34.09 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/b5954f4701f62b6/output.txt Total script time: 67.87 mins
|
|
Linux failures: Windows failures (unit tests, it's a timeout): Windows failures (integration tests, all because of timeouts): The windows unit test timeout is the same across the last two runs. |
|
/botio unittest |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.193.163.58:8877/de6a45131497f86/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.241.84.105:8877/de3cbe6fa74fab4/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/de3cbe6fa74fab4/output.txt Total script time: 2.49 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/de6a45131497f86/output.txt Total script time: 8.65 mins
|
44996da to
c24487e
Compare
This commit is a first step towards mozilla#6419, and it can also help with first compute which ops can affect what is visible in that part of the page. This commit adds logic to track operations with their respective bounding boxes. Only operations that actually cause something to be rendered have a bounding box and dependencies. Consider the following example: ``` 0. setFillRGBColor 1. beginText 2. showText "Hello" 3. endText 4. constructPath [...] -> eoFill ``` here we have three rendering operations: the showText op (2) and the path (4). (2) depends on (0), (1) and (3), while (4) only depends on (0). Both (2) and (4) have a bounding box. This tracking happens when first rendering a PDF: we then use the recorded information to optimize future partial renderings of a PDF, so that we can skip operations that do not affected the PDF area on the canvas. All this logic only runs when the new `enableOptimizedPartialRendering` preference, disabled by default, is enabled. The bounding boxes and dependencies are also shown in the pdfBug stepper. When hovering over a step now: - it highlights the steps that they depend on - it highlights on the PDF itself the bounding box
c24487e to
6a22da9
Compare
|
/botio unittest |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.241.84.105:8877/fdc58ac905120ed/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @nicolo-ribaudo received. Current queue size: 0 Live output at: http://54.193.163.58:8877/ccac5fd94e8b80f/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/fdc58ac905120ed/output.txt Total script time: 2.40 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/ccac5fd94e8b80f/output.txt Total script time: 7.87 mins
|
|
/botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @calixteman received. Current queue size: 0 Live output at: http://54.193.163.58:8877/86aa7b57d36ff5c/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @calixteman received. Current queue size: 0 Live output at: http://54.241.84.105:8877/86a45629e3f18f6/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/86a45629e3f18f6/output.txt Total script time: 17.42 mins
|
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/86aa7b57d36ff5c/output.txt Total script time: 30.19 mins
|
|
Nice work; thanks! |
|
I have a couple of follow up PRs coming. |
I started working towards #6419. This PR introduces the logic to track where different elements of the PDF are rendered, and hooks it up to the debugger since @calixteman mentioned that it would be useful.
I'm marking this as draft because there are a few changes I need to make:
canvas.jsto receive the index as a param, rather than returning a function that takes the indexCanvasRecorder, so that when not recording it doesn't have a performance impact.However, I'd love to receive feedback on the direction.
Commit 1:
Commit 2:
This is an example of what the debugger integration looks like (note: I couldn't figure out how to make my cursor show up in the recording 😅 I'm moving it over the steps list):
Screen.Recording.2024-11-14.at.16.35.58.mov
By default it doesn't show all the bounding boxes because on some PDFs it's too much noise, but if you click on the checkbox then it shows the boxes and you can click on a box to scroll into view the corresponding ops.