-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add logic to track rendering area of various PDF ops #19043
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
base: master
Are you sure you want to change the base?
Add logic to track rendering area of various PDF ops #19043
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
Track marked content blocks
Add missing recordFullPageBBox to CanvasNestedDependencyTracker
Mark pr8808-partial as known partial mismatch
Fix _createMaskCanvas tracking
Mark issue12295-partial as known partial mismatch
Use full page bbox for type 3 fonts with no bbox
Track bbox of paintImageMaskXObjectGroup
Mark bug1365930-partial as known partial mismatch
Use CanvasNestedDependencyTracker for type3 fonts
Cache variables in hot loops
Track paintInlineImageXObjectGroup bbox before restoring ctx
da1864f
to
e938c4e
Compare
Mark `issue1905-partial` as a known mismatch (it's not visible, at the edge)
Track bbox in paintChar when patternFill/patternStroke
Fix tracking of smask group transform
Mark issue1466-partial as known partial mismatch
Avoid multiple CanvasNestedDependencyTracker
Mark bug1898802-partial as known mismatch
Fix bbox computing with rotations
Fix bbox computing of text drawn by clipping
Mark bug887152-partial as known partial mismatch
Mark issue4926-partial as known mismatch
Track text-based clip as dependencies
Handle unbalanced save/restore in type3 fonts
Ensure that there is a bbox in type3 font operations
Fallback for fonts without bbox
Track fill dependencies for shadingFill
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.js
to 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.