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

Crash when rendering position absolute display flex element due to non-iterable PageBox #1536

Closed
n1ngu opened this issue Jan 10, 2022 · 5 comments
Labels
crash Problems preventing documents from being rendered
Milestone

Comments

@n1ngu
Copy link

n1ngu commented Jan 10, 2022

The recent update of weasyprint 54 raises an exception when rendering many of my templates due to the usage of absolute flex elements.

I think this html

<!doctype html>
<html>
  <head>
    <style>
p {
    position: fixed;
    display: flex;
}
    </style>
    <title>Test</title>
  </head>
  <body>
    <p>Hello</p>
  </body>
</html>

is enough to reproduce the issue.

AFAIU this changes f5d6d54#diff-3c982105b0ba6decc90731974c5bf2d4f37f0656b1ab8267bedecdf2e3d054d5 in the layout/absolute.py file might be the culprit of the issue: the parameters containing_blockand containing_block_sizes were swapped in the absolute_flex function definition but not its call from absolute_box_layout function (this is where the traces are coming from)

[...]
  File "/app/.venv/lib/python3.9/site-packages/weasyprint/layout/page.py", line 596, in make_page
    absolute_layout(
  File "/app/.venv/lib/python3.9/site-packages/weasyprint/layout/absolute.py", line 272, in absolute_layout
    new_box, resume_at = absolute_box_layout(
  File "/app/.venv/lib/python3.9/site-packages/weasyprint/layout/absolute.py", line 307, in absolute_box_layout
    new_box, resume_at = absolute_flex(
  File "/app/.venv/lib/python3.9/site-packages/weasyprint/layout/absolute.py", line 234, in absolute_flex
    cb_x, cb_y, cb_width, cb_height = containing_block_sizes
TypeError: cannot unpack non-iterable PageBox object

Edit: phrasing

@n1ngu
Copy link
Author

n1ngu commented Jan 10, 2022

Due to the amount of refactoring that went on that file, I am somewhat astray on how this should be addressed. I'd need a fair amount of guidance to contribute any kind of patch. I hope the posted html snippet aids to increase the test suite nonetheless.

@n1ngu n1ngu changed the title Fail to render position absolute display flex element due to non-iterable PageBox Crash when rendering position absolute display flex element due to non-iterable PageBox Jan 10, 2022
@liZe liZe added the crash Problems preventing documents from being rendered label Jan 10, 2022
@liZe liZe added this to the 54.1 milestone Jan 10, 2022
@liZe liZe closed this as completed in a10032c Jan 10, 2022
liZe added a commit that referenced this issue Jan 10, 2022
@liZe
Copy link
Member

liZe commented Jan 10, 2022

Hello!

Thanks for the bug report, and thanks a lot for the snippet! The bug was caused by the refactoring, and by these stupid original_cb/cb parameters (there’s already a TODO in the code about that). It should be fixed now.

@mgazzin
Copy link

mgazzin commented Jan 26, 2022

I have just installed today and it still have the bug. When are you going to update .whl @liZe @grewn0uille ?

@grewn0uille
Copy link
Member

Soon :)

@varac
Copy link

varac commented Jan 26, 2022

Using the example cli cmd from the docs:

❯ weasyprint http://weasyprint.org /tmp/weasyprint-website.pdf
...
   new_box, resume_at = absolute_box_layout(
  File "/home/varac/projects/pdf/WeasyPrint/.direnv/python-3.9.7/lib/python3.9/site-packages/weasyprint/layout/absolute.py", line 307, in absolute_box_layout
    new_box, resume_at = absolute_flex(
  File "/home/varac/projects/pdf/WeasyPrint/.direnv/python-3.9.7/lib/python3.9/site-packages/weasyprint/layout/absolute.py", line 234, in absolute_flex
    cb_x, cb_y, cb_width, cb_height = containing_block_sizes
TypeError: cannot unpack non-iterable BlockBox object

❯ weasyprint --version
WeasyPrint version 54.0

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