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

High values of colspan take too much time #1155

Closed
chrisfrigo1 opened this issue Jul 8, 2020 · 4 comments
Closed

High values of colspan take too much time #1155

chrisfrigo1 opened this issue Jul 8, 2020 · 4 comments
Labels
performance Too slow renderings
Milestone

Comments

@chrisfrigo1
Copy link

chrisfrigo1 commented Jul 8, 2020

Hi, can't seem to work out why specifically this html string is causing weasyprint to hang during conversion. i'm using the latest version 51. Any suggestions would be appreciated.

example-html.txt

@liZe liZe added the crash Problems preventing documents from being rendered label Jul 8, 2020
@Tontyna
Copy link
Contributor

Tontyna commented Jul 8, 2020

It's because of colspan="65534"

@liZe
Copy link
Member

liZe commented Jul 8, 2020

It's because of colspan="65534"

Then I suppose it’s not struck, it’s just extremely slow 😄. There’s an optimization waiting to be found.

@chrisfrigo1
Copy link
Author

thanks guys. appreciated.

@liZe liZe added performance Too slow renderings and removed crash Problems preventing documents from being rendered labels Aug 3, 2020
@liZe liZe changed the title weasyprint convert html to png is hanging on specific html High values of colspan take too much time Jan 16, 2021
@liZe liZe added this to the 63.0 milestone Aug 10, 2024
@liZe
Copy link
Member

liZe commented Aug 11, 2024

There are horrible nested loops here:

for span in range(1, grid_width):
percentage_contributions = []
for i in range(grid_width):
percentage_contribution = intrinsic_percentages[i]
for j in range(len(zipped_grid[i])):
indexes = [k for k in range(i + 1) if grid[j][k]]

Here’s a fix that makes colspan=2000 take less than a second instead of 2 mins 30 on my computer. With the original 65534 value, it takes about 25 seconds. That’s not perfect, but I think it’s OK for such a dirty corner case 😄.

@liZe liZe closed this as completed in f17bd4b Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Too slow renderings
Projects
None yet
Development

No branches or pull requests

3 participants