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

'column-span: all' triggers all kinds of errors #984

Closed
Tontyna opened this issue Oct 29, 2019 · 10 comments
Closed

'column-span: all' triggers all kinds of errors #984

Tontyna opened this issue Oct 29, 2019 · 10 comments
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@Tontyna
Copy link
Contributor

Tontyna commented Oct 29, 2019

Snippet to produce duplicates:

<style>    
@page {
  size: 14cm 14cm;
}
.col2 {columns: 2}
h2 {column-span: all}
</style>
<div class="col2">
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
<h2>full-width heading</h2> 
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
</div>

Snippet to produce infinite loop:

<style>    
@page {
  size: 14cm 14cm;
}
.col2 {columns: 2}
h2 {column-span: all}
</style>
<div class="col2">
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
<h2>full-width heading</h2> 
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
</div>

Snippet to crash with AssertionError:

<style>    
@page {
  size: 14cm 14cm;
}
.col2 {columns: 2}
h2 {column-span: all}
</style>
<div class="col2">
<h2>full-width heading</h2> 
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp
abc def lorem ipsum dolor sit amet etc pp

ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
ghi jkl lorem ipsum dolor sit amet etc pp
</div>
@fabiobatalha
Copy link

Hello @Tontyna

Please, take a look at: #981 (comment)

This may give some more clarifications about the IndexError Exceptions.

@Tontyna
Copy link
Contributor Author

Tontyna commented Nov 1, 2019

The special treatment of boxes with column-span:all inside columns_layout() destorts the skip_stack for subsequent multi-columned boxes within the same parent box.
This corrupted skip_stack is harmless, when the multi-column block doesn't cross the page. As soon as a next page is due the crash is inevitable.

Tried to defang and repair the wrecked skip_stack and to skip the already rendered column-span:all box -- to no avail.

In desparation I finally brute-forced the initial original root-tree to separate the column-span:all boxes from their surrounding multi-column content, like that:

original tree

box columns: 2
 + box before1
 + box before2
 + box before3
 + box column-span:all
 + box after1
 + box after2

defused tree

anonymous wrapping box
+ box columns: 2
   + box before1
   + box before2
   + box before3
+ box column-span:all
+ box columns: 2
   + box after1
   + box after2

Of course, though the crashes disappear and the snippets are balanced and rendered as expected, this is an insane solution.

Hoping for somebody else finding the fix, someone more familiar with skip-stacks than I am.

@liZe
Copy link
Member

liZe commented Nov 8, 2019

As for flexboxes, where the order of rendered boxes can be changed, columns layout changes the tree in a complex way, totally breaking the skip_stack / resume_at mechanism.

There's no need to find a workaround for that. It's broken.

To close #36 (yes, yes, I know, it's nearly 7 years old…) we'll have change the way skip stacks are stored. We don't have the same needs depending on the layout of the box, so we can have different structures at different levels. And, of course, as we can have parallel flows, we'll have more than one for each level.

That's the fix we need.

@liZe liZe added the crash Problems preventing documents from being rendered label Nov 8, 2019
@Tontyna
Copy link
Contributor Author

Tontyna commented Nov 8, 2019

Therefore I propose to remove the column-span:all feature from WeasyPrint. It's doomed to crash unless someone undertakes the redesign of the skip_stack.

@liZe
Copy link
Member

liZe commented Nov 9, 2019

Therefore I propose to remove the column-span:all feature from WeasyPrint. It's doomed to crash unless someone undertakes the redesign of the skip_stack.

It's time for this redesign. Let's say version 52 is the moment when we implement parallel flows.

@EvanEdwards
Copy link

I'm not sure if this is the same issue, but it may be close enough to warrant placing it here rather than in its own issue. The bottom of the box carries over for all pages (at minimum padding and margin) when there is a colum-span:all.

Here's a bare bones example that demonstrates the issue as presented in this image:

image

<!DOCTYPE html>
<html><head><title>Example</title>
<style>

h1 {
  padding: .25in;
  background: blue;
  color: white;
  break-before: always;
  column-span: all;
  border-radius: .1in; /* to demonstrate it is the bottom */
}

section {
  columns: 2;
}

</style>
</head>
<body>

<section>
<h1>This is on blue.</h1>

<p>On the second page of this, there is the bottom padding from the h1 repeated, plus the bottom margin.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
<p>Text that goes on for quite awhile, filling the page and going to the next page.  This paragraph is simply repeated several times to demonstrate this effect.</p>
</section>


</body>
</html>

@EvanEdwards
Copy link

Confirmed to still have the same issue in release 52.

(Also: thank you for release 52!!!)

@zopyx
Copy link

zopyx commented Jul 26, 2021

This issue is also the reason for the broken rendering

https://beta.print-css.rocks/lesson/lesson-multi-columns

@liZe
Copy link
Member

liZe commented Apr 5, 2022

Related to (duplicate of?) #1604.

@liZe liZe added this to the 55.0 milestone Apr 5, 2022
@liZe
Copy link
Member

liZe commented Apr 5, 2022

If other people are interested in reproducing the bugs, the original samples give the right errors using:

body {
  font-family: Liberation Serif;
  font-size: 13pt;
}

@liZe liZe closed this as completed in 6ba031e Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

5 participants