Macro MAX_OPEN_FACES on cairo-ft-font.c not required?
I was getting a crash when running more than 10 instances of Pango in separate threads and I could track the crash to cairo's library in the cairo-ft-font.c file. At function _cairo_ft_unscaled_font_set_scale. After clearing the assetion on line 856:
assert (unscaled->face != NULL);
Another thread was destroying the face and setting the unscaled->face pointer to NULL, even when the the threads was using a totally independent fontConfig, and its own private font file. Then I found that what was destroying the font face was the while loop in the function _cairo_ft_unscaled_font_lock_face, line 719:
719 while (font_map->num_open_faces >= MAX_OPEN_FACES)
...
728 _font_map_release_face_lock_held (font_map, entry);
The problem was that when running 13 instances of PangoCairo simultaneously, everytime that the number of open font faces exceeded the Macro:
#define MAX_OPEN_FACES 10
The loop was destroying some faces to bring the number of open faces down to 10. Occasionally it destroys a face being used by another thread the crash occurred.
I noticed that the macro was created some 15 years ago, when the code in this file had a completely different structure, and just by removing the macro and the loop that uses it mentioned above the crash stops to happen in my application running now even more than 13 instances of Pango/Cairo simultaneously.
Does this macro means anything in the rest of the code this days? I couldn't find it anywhere else in the cairo's source code. Is it just a thing that wasn't cleaned-up throughout the years?