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

CSS border-radius makes pdf rendering very slow #396

Closed
mndzielski opened this issue Oct 15, 2019 · 2 comments
Closed

CSS border-radius makes pdf rendering very slow #396

mndzielski opened this issue Oct 15, 2019 · 2 comments

Comments

@mndzielski
Copy link

mndzielski commented Oct 15, 2019

Hi, I discover that using border-radius with background-image makes that pdf is rendering much longer.

CSS code here:
div.avatar { margin-left: auto; margin-right: auto; height: 200px; width: 160px; background-size: cover; background-position: center center; background-repeat: no-repeat; border-radius: 4px; background-image: url(' base64 here ...') }

HTML:
<div class="avatar"></div>

With border-radius property process takes ~8000ms,
without <70ms. Is there any solution to provide better performance?

@danfickle
Copy link
Owner

Hi @mndzielski,

Although, in my testing the difference wasn't as great as yours, I confirmed the problem and found the culprit. It turns out the AWT Area constructor when passed a shape with curves is very slow (taking over 16 seconds of 22 seconds total in my test and eating up memory). In theory a fix should be easy as the fast mode renderer does not actually need the Area, just the underlying Shape.

However, the Area also seems to be slightly different to its passed in Shape, which means discarding the Area means breaking a lot of tests.

In conclusion, I'll have to experiment more with the Area class, seeing how it changes a Shape before applying a fix.

In the meantime, you may wish to up the memory used by the JVM, as the greater difference between my test and yours may be garbage collection pressure as Area uses a lot of memory (up to 200MB more in my simple test between border-radius and no border-radius).

danfickle added a commit that referenced this issue Nov 6, 2019
because creating such an Area is very very slow. This is a quick fix - we should really never use an Area but this breaks many tests with square borders by a pixel for some reason.

With visual regression test for broder radius CSS.
@danfickle
Copy link
Owner

Ok @mndzielski,

I have applied a quick fix by no longer creating an Area when there is border radius involved. This is not ideal but didn't break any tests (because we had no tests with border radius!) and fixes the speed issue.

As always, thanks for reporting!

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

No branches or pull requests

2 participants