-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Create shading patterns the size of the current path. (bug 1722807) #14230
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
Conversation
Some notes from performance testing:
-- Grouped By pdf, stat, browser --
|
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 1 Live output at: http://54.241.84.105:8877/2bfc0cde59f7be6/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 1 Live output at: http://54.193.163.58:8877/4fa737c913b1a67/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/2bfc0cde59f7be6/output.txt Total script time: 23.11 mins
Image differences available at: http://54.241.84.105:8877/2bfc0cde59f7be6/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/4fa737c913b1a67/output.txt Total script time: 34.45 mins
Image differences available at: http://54.193.163.58:8877/4fa737c913b1a67/reftest-analyzer.html#web=eq.log |
Are these chrome annotation and form failures new? They seem to work fine locally in tests and in the viewer.... |
I cannot recall having seen them before, unfortunately.
When testing this patch in Google Chrome locally, I can reproduce the test-failures. However, there's no errors in the console that'd explain the rendering failures. |
9f71e42
to
4e772f2
Compare
I haven't fixed the annotation/form bug yet. Just pushing so I can try this out on linux/windows... |
src/display/pattern_helper.js
Outdated
const ownerBBox = owner.current.getClippedPathBoundingBox( | ||
pathType, | ||
ctx.mozCurrentTransform | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the previous test-results, there's also a breaking error which I assume is caused by this line (since this method uses Util.intersect
which can return null
).
TEST-UNEXPECTED-FAIL | test failed issue6961 | in firefox | page1 round 1 | render : TypeError: can't access property 2, ownerBBox is null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, I totally missed that! It seems to fix the other issues. However, that PDF is now displaying wrong in a new way (it's wrong as is too). The computed bounding box for the shading is slightly too small. I'm not sure why yet. It's not going to be fun to debug, since that PDF has thousands of paths. :(
I still don't quite understand why breaking that PDF, breaks other PDFs. We shouldn't be reusing any canvases, but we must not be cleaning up something correctly when an error happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could the problem be that we're actually re-using the same <canvas>
for every page/document during tests, thus possibly keeping some bad graphics-state alive?
A while back I wanted to see if we could get rid of some intermittent failures by always creating a new <canvas>
during tests, please see PR #12960; maybe we should see if that'd fixed these problems and potentially land that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That brings up a good point! The canvas state should be getting reset when we assign to the width/height in driver.js, but in chrome we add our polyfill for mozCurrentTransform and that does NOT get reset. That would explain why this was only an issue in chrome. I'm thinking we should either override the width/height attributes of the canvas to reset the transform stuff or manually wipe out the transform stack and reset the current transform. The former is probably less error prone since we wouldn't have to remember to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for the bounding box being wrong in issue6961, that is because of #14241.
Previously, when we created a shading pattern canvas we created it as the same size as the page. This was good for caching if the same pattern was used over and over again, but when lots of different shadings are created that caused us to create many full page canvases. Instead of creating the full page canvses, create the canvas as the same size as the current path bounding box. This reduces memory consumption by a lot since most paths are pretty small. Also, in real world PDFs it's rare for a shading (non shading fill) to be reused over and over again. Bug 1721949 is an example where the same pattern is reused and it will be slightly slower than before.
4e772f2
to
b56cca0
Compare
/botio test |
From: Bot.io (Linux m4)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 1 Live output at: http://54.241.84.105:8877/648f5c85255a8e3/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_test from @brendandahl received. Current queue size: 2 Live output at: http://54.193.163.58:8877/4137d3fe75c1c05/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/648f5c85255a8e3/output.txt Total script time: 21.10 mins
Image differences available at: http://54.241.84.105:8877/648f5c85255a8e3/reftest-analyzer.html#web=eq.log |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/4137d3fe75c1c05/output.txt Total script time: 41.97 mins
Image differences available at: http://54.193.163.58:8877/4137d3fe75c1c05/reftest-analyzer.html#web=eq.log |
/botio browsertest |
From: Bot.io (Windows)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/749ae76a4cf4950/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/39c04ff731af90b/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/39c04ff731af90b/output.txt Total script time: 18.50 mins
Image differences available at: http://54.241.84.105:8877/39c04ff731af90b/reftest-analyzer.html#web=eq.log |
/botio-linux browsertest |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/c93d4e50c70dd2b/output.txt |
/botio-linux browsertest |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 1 Live output at: http://54.241.84.105:8877/f4cf9759fe79ca9/output.txt |
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/749ae76a4cf4950/output.txt Total script time: 37.61 mins
Image differences available at: http://54.193.163.58:8877/749ae76a4cf4950/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/c93d4e50c70dd2b/output.txt Total script time: 18.58 mins
Image differences available at: http://54.241.84.105:8877/c93d4e50c70dd2b/reftest-analyzer.html#web=eq.log |
/botio-linux browsertest |
From: Bot.io (Linux m4)ReceivedCommand cmd_browsertest from @Snuffleupagus received. Current queue size: 1 Live output at: http://54.241.84.105:8877/5fbcfe3d3546bce/output.txt |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/f4cf9759fe79ca9/output.txt Total script time: 18.60 mins
Image differences available at: http://54.241.84.105:8877/f4cf9759fe79ca9/reftest-analyzer.html#web=eq.log |
From: Bot.io (Linux m4)FailedFull output at http://54.241.84.105:8877/5fbcfe3d3546bce/output.txt Total script time: 20.23 mins
Image differences available at: http://54.241.84.105:8877/5fbcfe3d3546bce/reftest-analyzer.html#web=eq.log |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me, thank you!
/botio makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 1 Live output at: http://54.193.163.58:8877/39fe3bab8910866/output.txt |
From: Bot.io (Linux m4)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.241.84.105:8877/a195abca852cd53/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.241.84.105:8877/a195abca852cd53/output.txt Total script time: 20.87 mins
|
From: Bot.io (Windows)FailedFull output at http://54.193.163.58:8877/39fe3bab8910866/output.txt Total script time: 31.42 mins
|
/botio-windows makeref |
From: Bot.io (Windows)ReceivedCommand cmd_makeref from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.193.163.58:8877/330df8d5dadae8f/output.txt |
From: Bot.io (Windows)SuccessFull output at http://54.193.163.58:8877/330df8d5dadae8f/output.txt Total script time: 38.22 mins
|
Awesome work on this and the other PRs; thank you! |
Previously, when we created a shading pattern canvas we created it
as the same size as the page. This was good for caching if the same
pattern was used over and over again, but when lots of different
shadings are created that caused us to create many full page
canvases.
Instead of creating the full page canvses, instead create the canvas
as the same size as the current path bounding box. This reduces memory
consumption by a lot since most paths are pretty small. Also, in real world
PDFs it's rare for a shading (non shading fill) to be reused over and over again.
Bug 1721949 is an example where the same pattern is reused and it will be slightly
slower than before.