Summary: | Improve thread safety of Cairo Font on Windows | ||
---|---|---|---|
Product: | cairo | Reporter: | Fan, Chun-wei <fanc999> |
Component: | win32 backend | Assignee: | cairo-bugs mailing list <cairo-bugs> |
Status: | RESOLVED MOVED | QA Contact: | cairo-bugs mailing list <cairo-bugs> |
Severity: | normal | ||
Priority: | medium | CC: | pavlushko |
Version: | unspecified | ||
Hardware: | Other | ||
OS: | Windows (All) | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | Attempt to make cairo-win32-font.c thread-safe |
Description
Fan, Chun-wei
2013-12-24 09:25:37 UTC
Created attachment 91176 [details] [review] Attempt to make cairo-win32-font.c thread-safe Hi, Lufy D.Monkey's have come up with a patch[1][2] that attempts to make cairo-win32- font.c thread-safe. I have adapted his patch (which was dated back to 2010) so that it fits in the current state of the code. Basically what happens is that the HDC's creations/releases are guarded by mutexes and the created HDC's are cached by thread id's so that they will need to be created and released less often. This does not yet fix the PangoCairo situation (although it would fare better there by reducing intermittent crashes by a whole lot, say from once every 8 runs to 30 runs or so), but I have used this cairocffi Python test[3] to test this code, and it seems that the fix will allow the test to pass, whereas the original code will fail with a MemoryError: ('cairo returned CAIRO_STATUS_NO_MEMORY: out of memory', 1L) [1]: http://lists.cairographics.org/archives/cairo/2010-July/020336.html [2]: http://lists.cairographics.org/archives/cairo/attachments/20100715/8b3a8f05/attachment-0001.obj [3]: https://gist.github.com/akx/7307462/raw/13c03a220662928778ab626625cd53251d1ec295/cairocffi-22.py Merry Christmas, and with blessings, thank you! How about making the static variable a TLS (Thread Local Storage) one? - static HDC hdc; + static __thread HDC hdc; -- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/cairo/cairo/issues/190. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.