pycairo icon indicating copy to clipboard operation
pycairo copied to clipboard

Out of memory on surface finish

Open eleroy opened this issue 4 years ago • 5 comments

In python 3.8, windows 10 x64, pycairo 1.20.1:

import cairo

with cairo.PDFSurface("example2.pdf", 200, 200) as surface:
    pass

surface = cairo.PDFSurface("example.pdf", 200, 200)
surface.finish()

The call with the context manager works, but the last line surface finish throws an out of memory error. This is now only possible to use the surface within the context manager for some reason ?

Does anyone have the same issue ?

Thank you

eleroy avatar Jun 24 '21 11:06 eleroy

Everything is working with these builds:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo

eleroy avatar Jun 24 '21 11:06 eleroy

Got exactly the same thing. Windows 10 64-bit, Python 3.9.1, pycairo 1.21.0. I also noticed the following crashes likewise (with cairo.MemoryError: out of memory at the show_page() call):

import cairo
with cairo.PDFSurface("test.pdf", 200, 200) as surface:
    cairo.Context(surface).show_page()

Basically pycairo is unusable for me here.

msh0 avatar Jun 07 '22 19:06 msh0

Everything is working with these builds:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo

Worked with the build found here, many thanks (this .whl collection has saved my skin quite a few times before). But the PyPI version remains entirely useless.

msh0 avatar Jun 07 '22 19:06 msh0

Everything is working with these builds:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo

@eleroy you're a champ. This solution really just saved me hours worth of headaches.

eddiethehuman avatar Jun 11 '22 14:06 eddiethehuman

Yeah, I can reproduce the error. On the packages version of Cairo on PyPI, I found the Cairo version bundled to be

>>> import cairo
>>> cairo.cairo_version()
11702

and on the wheel from https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo, it's

>>> import cairo
>>> cairo.cairo_version()
11600

So it must be something with the version of the library used. Also, the most recent version is 1.17.6 (developmental release) and I'll try and see if I can reproduce it there. I should also work on https://github.com/pygobject/pycairo/pull/243 someday. Edit: No I can't reproduce with wheels built with recent version 1.17.6

>>> import cairo
>>> cairo.cairo_version()
11706
>>> surface = cairo.PDFSurface("example.pdf", 200, 200)
>>> surface.finish()

naveen521kk avatar Jun 11 '22 14:06 naveen521kk

I can reproduce the issue with 1.22.0, but with 1.23.0, which includes the new cairo build everything seems to work now.

So I think this is fixed in the latest release.

lazka avatar Nov 28 '22 20:11 lazka

I assumed this was fixed in cairo then.

lazka avatar Jun 10 '23 16:06 lazka