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

Rendering issue on MacOS preview #2010

Closed
FozzieHi opened this issue Nov 24, 2023 · 7 comments
Closed

Rendering issue on MacOS preview #2010

FozzieHi opened this issue Nov 24, 2023 · 7 comments
Labels
bug Existing features not working as expected
Milestone

Comments

@FozzieHi
Copy link

FozzieHi commented Nov 24, 2023

I'm running into a rendering issue on MacOS preview, where neither text, nor images are rendered (but styling such as borders are).
rendering_issue

I'm converting a HTML document generated by Bikeshed, and the PDF does display correctly on readers such as Chrome and Firefox, so I'm reporting it here instead of on the Bikeshed repo, but can of course move it to there if need be.

I've attached the HTML document Bikeshed generates, and the output PDF WeasyPrint generates, and can provide more info if needed. Thanks!
index.zip

@FozzieHi
Copy link
Author

FozzieHi commented Nov 24, 2023

I've managed to get this down to a small reproducible by playing around with the CSS Bikeshed outputs. If you try and generate a PDF using the following HTML, any text or images in the document will not render using MacOS Preview (even those outside of the problematic tag), and a warning will be generated when trying to check the PDF using QPDF.

<html>
    <head>
        <style>
            :root {
                --p-text: currentcolor;
            }
            p {
                color: var(--p-text);
            }
        </style>
    </head>
    <body>
        <p>
            Test
        </p>
    </body>
</html>
$ qpdf --check test.pdf
WARNING: test.pdf object stream 13 (object 4 0, offset 179): unknown token while reading object; treating as string
checking test.pdf
PDF Version: 1.7
File is not encrypted
File is not linearized
qpdf: operation succeeded with warnings

@liZe liZe added the bug Existing features not working as expected label Nov 25, 2023
@liZe
Copy link
Member

liZe commented Nov 25, 2023

Hi!

Thanks for the bug report.

That’s a miracle to not get a crash in this case. That’s once again a problem like #1287, caused by #1165. We can definitely try to find a workaround, but the whole management of CSS functions has to be rewritten to get a real fix.

@FozzieHi
Copy link
Author

@liZe Thanks, do you mean #1165 instead of #1175?

I'm not very familiar with CSS in PDFs, but is there a way to just not render this specific styling so that the document as a whole would render fine? Is MacOS Preview correct to not render in this case, and other readers are just trying to work around the problem?

Also, this should probably be opened as a different issue, but is it worth running a QPDF check during the WeasyPrint processing, to outline warnings like these to the user? Otherwise, there is no output from WeasyPrint to indicate any kind of problem.

@liZe
Copy link
Member

liZe commented Nov 25, 2023

@liZe Thanks, do you mean #1165 instead of #1175?

I do (I’ve edited the comment.)

Is MacOS Preview correct to not render in this case, and other readers are just trying to work around the problem?

The PDF is broken, that’s a bug in WeasyPrint. It magically works in PDF.js, but it’s broken in some other rendering tools.

Also, this should probably be opened as a different issue, but is it worth running a QPDF check during the WeasyPrint processing, to outline warnings like these to the user? Otherwise, there is no output from WeasyPrint to indicate any kind of problem.

We already use Ghostscript to find these kind of bugs, and it also breaks with your example. We didn’t catch the bug earlier because this case wasn’t tested, that’s all. We’ll include a non-regression test when it’s solved!

I’m currently trying to fix the problem in a quite solid way.

@liZe
Copy link
Member

liZe commented Nov 25, 2023

We already use Ghostscript to find these kind of bugs, and it also breaks with your example.

We actually don’t fail on Ghostscript errors. Let’s fix that too!

@liZe liZe added this to the 61.0 milestone Nov 25, 2023
liZe added a commit that referenced this issue Nov 25, 2023
@liZe liZe closed this as completed in 6eb5f96 Nov 25, 2023
@liZe
Copy link
Member

liZe commented Nov 25, 2023

@FozzieHi the problem should be fixed in main, feedback is welcome!

@FozzieHi
Copy link
Author

@liZe Yup, that's fixed the issue. Thanks so much for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants