[cairo] Cairo 1.6.4 Quartz crash: CGImageCreateCopy misuse

Vladimir Vukicevic vladimir at pobox.com
Wed May 7 10:19:54 PDT 2008


On May 5, 2008, at 9:56 PM, Paul Messmer wrote:
>
> Yes, this fixes the problem for me (with a cast to make it compile  
> and another to silence a warning):
>
>    isurf_snap = (cairo_image_surface_t *) _cairo_surface_snapshot  
> ((cairo_surface_t *) isurf);
>
> And (as you said) every time I draw from a source image surface,  
> even the same one repeatedly, I see copies being made now in  
> _cairo_surface_fallback_snapshot.
>
> This is problematic for me as I might be printing large images  
> repeatedly on multiple pages, etc...  I've already kludged a work- 
> around without the patch by not releasing my surface pointers until  
> printing is complete, but that's clearly ugly (though then I never  
> copy the data).  I assume you meant I should look into using the  
> experimental *quartz-*cairo-image-surface? which I will investigate  
> when I have more time.  Hopefully in the long term a different fix  
> than this patch is done in Cairo so that clients don't have to  
> special-case Quartz printing to avoid copies for each painting of a  
> single image surface.

Er right, yes, the quartz image surface.  I don't think there's much  
that can be done here to fix the problem inside Cairo -- Quartz's data  
ownership model for patterns when printing is pretty painful.  I have  
a couple of ideas, but all of them have problems; perhaps the most  
promising would be to create a copy/snapshot once and then attach it  
to the source surface... but we'd need some way to clean those up.

Storing your images in a quartz_image_surface should prevent the  
copies from being made, though again, you have to be careful to create  
the cairo image surface so that cairo allocates and owns its memory  
(or if you allocate the memory, only deallocate it using a custom user  
data destructor on the surface).

     - Vlad

> ----------------------------------------
>> CC: paulmessmer at hotmail.com; cairo at cairographics.org
>> From: vladimir at pobox.com
>> To: vladimir at pobox.com
>> Subject: Re: [cairo] Cairo 1.6.4 Quartz crash: CGImageCreateCopy  
>> misuse
>> Date: Mon, 5 May 2008 13:00:57 -0700
>>
>>
>> Paul,
>>
>> Can you try the attached patch and see if it fixes the problem for
>> you?  Note that in most cases this will result in a copy of the image
>> data being created -- to avoid this, you should use the  
>> (experimental)
>> cairo-image-surface and have it backed by an image surface that owns
>> its own data.  That way the lifecycle issues are handled via
>> refcounting, and no copy is needed.
>>
>>     - Vlad
>>



More information about the cairo mailing list