Is font face reference counting broken?

Carl Worth cworth at cworth.org
Wed May 15 19:48:10 UTC 2024


On Wed, May 15 2024, Uli Schlachter wrote:
> Ah, okay. I was thinking about a long-running program. There, newer 
> fonts would eventually cause the old, stale ones to be evicted from the 
> cache. At that point, the callback would be called.
>
> In such a situation, using cairo_debug_reset_static_data() could be 
> problematic, because "something else" could still be having cairo 
> objects alive.

FWIW, I don't think it would be problematic. If "something else" still
has cairo objects alive, then that something else will also have
reference counts for that.

One impact of calling cairo_debug_reset_static_data() is that it would
flush all the caches so in a long-running program like this, that could
have a negative impact on performance.

That's why this functionality is relegated to a "debug" namespace with
the "cairo_debug" prefix. It's not expected that this function would be
called in "production code" (such as the long-running case you're
imagining).

But there's nothing about cairo_debug_reset_static_data that should make
it inherently unsafe nor unpredictable in how it behaves.

-Carl


More information about the cairo mailing list