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

Line breaking simplification breaks PDF RFC generation #973

Closed
kitterma opened this issue Oct 18, 2019 · 9 comments
Closed

Line breaking simplification breaks PDF RFC generation #973

kitterma opened this issue Oct 18, 2019 · 9 comments
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@kitterma
Copy link
Contributor

This is a bug I'm forwarding on behalf of a Debian user:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=942366

The xml2rfc program uses WeasyPrint to generate PDF versions of IETF RFCs. Up to WeasyPrint version 49, it worked. In version 50, it does not. I bisected the code and it starts failing after the line breaking redesign commit (f1b1d14).

There is an attachment in the Debian bug that shows the exact error. It also gives instructions on replicating the bug which worked for me.

I don't believe this was meant to be an API breaking change, so I think it's reasonably something that should be addressed in WeasyPrint.

Scott K

@kitterma
Copy link
Contributor Author

Forgot to mention, in case it matters, this is with python3.7.

@levkowetz
Copy link

The xml provided in the original bug report won't be helpful in tracking down the bug. I'm providing the HTML and 2 css snippets that are handed to WeasyPrint as a result of that XML:

https://tools.ietf.org/src/xml2rfc/issue/weasyprint/973/sample.html
https://tools.ietf.org/src/xml2rfc/issue/weasyprint/973/sample_1.css
https://tools.ietf.org/src/xml2rfc/issue/weasyprint/973/sample_2.css

Best regards,
Henrik

@Tontyna
Copy link
Contributor

Tontyna commented Oct 19, 2019

@levkowetz -- feeding the html and css to my WeasyPrint v50 renders without problem. Using v49 I see no difference in the PDFs.

So what's the actual error? Could you provide WeasyPrint's stack trace? Since you mention f1b1d14 I guess it's a crash with an IndexError or AssertionError and a duplicate of #953.

@kitterma
Copy link
Contributor Author

Here's the stack trace from the original bug reporter. I was able to replicate this (using his xml and xml2rfc):

Traceback (most recent call last):
File "/usr/bin/xml2rfc", line 11, in
load_entry_point('xml2rfc==2.32.0', 'console_scripts', 'xml2rfc')()
File "/usr/lib/python3/dist-packages/xml2rfc/run.py", line 615, in main
writer.write(filename)
File "/usr/lib/python3/dist-packages/xml2rfc/writers/pdf.py", line 100, in write
pdf = self.pdf()
File "/usr/lib/python3/dist-packages/xml2rfc/writers/pdf.py", line 89, in pdf
pdf = writer.write_pdf(None, stylesheets=[ css, page_css ])
File "/usr/lib/python3/dist-packages/weasyprint/init.py", line 211, in write_pdf
font_config=font_config).write_pdf(
File "/usr/lib/python3/dist-packages/weasyprint/init.py", line 168, in render
font_config)
File "/usr/lib/python3/dist-packages/weasyprint/document.py", line 393, in _render
[Page(page_box, enable_hinting) for page_box in page_boxes],
File "/usr/lib/python3/dist-packages/weasyprint/document.py", line 393, in
[Page(page_box, enable_hinting) for page_box in page_boxes],
File "/usr/lib/python3/dist-packages/weasyprint/layout/init.py", line 126, in layout_document
pages = list(make_all_pages(context, root_box, html, pages))
File "/usr/lib/python3/dist-packages/weasyprint/layout/pages.py", line 803, in make_all_pages
page, resume_at = remake_page(i, context, root_box, html)
File "/usr/lib/python3/dist-packages/weasyprint/layout/pages.py", line 742, in remake_page
page_number, page_state)
File "/usr/lib/python3/dist-packages/weasyprint/layout/pages.py", line 553, in make_page
positioned_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 510, in block_container_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 63, in block_level_layout
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 77, in block_level_layout_switch
page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 130, in block_box_layout
absolute_boxes, fixed_boxes, adjoining_margins)
File "/usr/lib/python3/dist-packages/weasyprint/layout/blocks.py", line 376, in block_container_layout
for line, resume_at in lines_iterator:
File "/usr/lib/python3/dist-packages/weasyprint/layout/inlines.py", line 53, in iter_line_boxes
absolute_boxes, fixed_boxes, first_letter_style)
File "/usr/lib/python3/dist-packages/weasyprint/layout/inlines.py", line 70, in get_next_linebox
skip_stack = skip_first_whitespace(linebox, skip_stack)
File "/usr/lib/python3/dist-packages/weasyprint/layout/inlines.py", line 210, in skip_first_whitespace
result = skip_first_whitespace(box.children[index], next_skip_stack)
File "/usr/lib/python3/dist-packages/weasyprint/layout/inlines.py", line 196, in skip_first_whitespace
assert next_skip_stack is None
AssertionError
make: *** [Makefile:18: draft-deremin-test.pdf] Error 1

@kitterma
Copy link
Contributor Author

Looks like you are correct. I can also confirm that with the changes from #956 the problem does not happen anymore.

@Tontyna
Copy link
Contributor

Tontyna commented Oct 19, 2019

So I'd say: Status == waiting for @liZe to merge #956

@liZe
Copy link
Member

liZe commented Oct 22, 2019

So I'd say: Status == waiting for @liZe to merge #956

I'm sorry, I'm late! I currently spend most of my spare time organizing PyConFr, I hope that I'll find the time soon to look at the looooong list of issues in my todo list.

@Tontyna
Copy link
Contributor

Tontyna commented Oct 22, 2019

No worries -- WeasyPrint will survive without bug fixes until 3rd of November. All the best for PyConFr!

@liZe
Copy link
Member

liZe commented Nov 7, 2019

Fixed by #956, thanks @Tontyna 😻.

@liZe liZe closed this as completed Nov 7, 2019
@liZe liZe added this to the 51 milestone Nov 7, 2019
@liZe liZe added the crash Problems preventing documents from being rendered label Nov 7, 2019
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

4 participants