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

CAIRO_STATUS_NO_MEMORY when using @font-face #441

Closed
cuu508 opened this issue Mar 11, 2017 · 3 comments
Closed

CAIRO_STATUS_NO_MEMORY when using @font-face #441

cuu508 opened this issue Mar 11, 2017 · 3 comments
Labels
bug Existing features not working as expected crash Problems preventing documents from being rendered
Milestone

Comments

@cuu508
Copy link

cuu508 commented Mar 11, 2017

weasyprint sometimes crashes with a "CAIRO_STATUS_NO_MEMORY" error when rendering documents with @font-face CSS rules.

The crashes are not deterministic, same document may render fine 100 times, and crash on the 101th time.

Test case:

from weasyprint import HTML

html = b"""
<style>
  @font-face {
    font-family: DejaVu;
    src: local(DejaVu Sans);
  }
  html {
    font-family: DejaVu;
  }
</style>
lorem ipsum
<img src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjEiIGhlaWdodD0iMSI+PHRleHQ+YTwvdGV4dD48L3N2Zz4K"/>
"""

for i in range(0, 1000):
    print("Iteration %d" % i)
    HTML(string=html).write_pdf()

Some previous discussion is in #103

@liZe liZe added bug Existing features not working as expected crash Problems preventing documents from being rendered labels Mar 11, 2017
@liZe
Copy link
Member

liZe commented Mar 11, 2017

Various hints for anyone interested in fixing this issue:

  • Only happens with both HTML text using @font-face and SVG rendering with text (not related to the font family used in the SVG).
  • Only happens when the SVG is rendered after the HTML text (only a Pango warning otherwise).
  • Only happens when writing a PDF (not with PNG, not with only Document.render()).

@Mihara
Copy link

Mihara commented Apr 4, 2017

Ow. I just stepped on that.
Somehow, I wasn't able to stop it from crashing even when excising all SVG from output. Only switching to loading fonts with local() prevented crashes reliably.

@liZe
Copy link
Member

liZe commented Oct 4, 2017

That's magically fixed by f5367c8.

Other rendering errors could happen before, but they were not fatal as this one. The font was sometimes removed from filesystem before the surface was written on the output PDF/image.

@liZe liZe closed this as completed Oct 4, 2017
netbsd-srcmastr referenced this issue in NetBSD/pkgsrc Oct 9, 2017
Version 0.41
------------

Released on 2017-10-05.

WeasyPrint now depends on pdfrw >= 0.4.

New features:

* `#471 <https://github.com/Kozea/WeasyPrint/issues/471>`_:
  Support page marks and bleed.

Bug fixes:

* `#513 <https://github.com/Kozea/WeasyPrint/issues/513>`_:
  Don't crash on unsupported image-resolution values.
* `#506 <https://github.com/Kozea/WeasyPrint/issues/506>`_:
  Fix @font-face use with write_* methods.
* `#500 <https://github.com/Kozea/WeasyPrint/pull/500>`_:
  Improve readability of _select_source function.
* `#498 <https://github.com/Kozea/WeasyPrint/issues/498>`_:
  Use CSS prefixes as recommanded by the CSSWG.
* `#441 <https://github.com/Kozea/WeasyPrint/issues/441>`_:
  Fix rendering problems and crashes when using @font-face.
* `bb3a4db <https://github.com/Kozea/WeasyPrint/commit/bb3a4db>`_:
  Try to break pages after a block before trying to break inside it.
* `1d1654c <https://github.com/Kozea/WeasyPrint/commit/1d1654c>`_:
  Fix and test corner cases about named pages.

Documentation:

* `#508 <https://github.com/Kozea/WeasyPrint/pull/508>`_:
  Add missing libpangocairo dependency for Debian and Ubuntu.
* `a7b17fb <https://github.com/Kozea/WeasyPrint/commit/a7b17fb>`_:
  Add documentation on logged rendering steps.
netbsd-srcmastr referenced this issue in NetBSD/pkgsrc Oct 22, 2017
Version 0.41
------------

Released on 2017-10-05.

WeasyPrint now depends on pdfrw >= 0.4.

New features:

* `#471 <https://github.com/Kozea/WeasyPrint/issues/471>`_:
  Support page marks and bleed.

Bug fixes:

* `#513 <https://github.com/Kozea/WeasyPrint/issues/513>`_:
  Don't crash on unsupported image-resolution values.
* `#506 <https://github.com/Kozea/WeasyPrint/issues/506>`_:
  Fix @font-face use with write_* methods.
* `#500 <https://github.com/Kozea/WeasyPrint/pull/500>`_:
  Improve readability of _select_source function.
* `#498 <https://github.com/Kozea/WeasyPrint/issues/498>`_:
  Use CSS prefixes as recommanded by the CSSWG.
* `#441 <https://github.com/Kozea/WeasyPrint/issues/441>`_:
  Fix rendering problems and crashes when using @font-face.
* `bb3a4db <https://github.com/Kozea/WeasyPrint/commit/bb3a4db>`_:
  Try to break pages after a block before trying to break inside it.
* `1d1654c <https://github.com/Kozea/WeasyPrint/commit/1d1654c>`_:
  Fix and test corner cases about named pages.

Documentation:

* `#508 <https://github.com/Kozea/WeasyPrint/pull/508>`_:
  Add missing libpangocairo dependency for Debian and Ubuntu.
* `a7b17fb <https://github.com/Kozea/WeasyPrint/commit/a7b17fb>`_:
  Add documentation on logged rendering steps.
@liZe liZe added this to the v0.40 milestone Jan 26, 2018
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 crash Problems preventing documents from being rendered
Projects
None yet
Development

No branches or pull requests

3 participants