On Sat, Jan 12, 2008 at 11:57:26PM +0000, Joel Holdsworth wrote:
Hi All,
I'm wondering how easy it would be to make the whole inkscape back-end thread safe, so that for example, SVGs can be parsed and rendered from within worker threads.
This is not considered an 'easy' undertaking, however it's been a work in progress, and the steps involved in making it happen have been relatively well analyzed, if you would be interested in working on it.
Does anyone have any idea why it's not thread-safe already?
Mental can speak most authoritatively on it, but as I understand it, there are assumptions built into our rendering layer that make it difficult. On the frontend, I've heard from Kees Cook that gtk is tough to do on top of multi-threaded apps, although I don't know if that would affect multithreading on the backend.
If I recall correctly from the prior times this question has come up, while using threading for the whole Inkscape backend is tricky, it's conceivable that specific isolated areas of the codebase could be run as independent threads, such as for preview images in file dialogs. I don't know the status of work done along these lines however.
In any case, I don't believe anyone's opposed in principle to this, just that it may involve a lot of challenging work to avoid bugs.
The reason I'm asking is because I've noticed a couple of scenarious such as PNG export, and quickly flicking between complex SVG files in the file dialogs, where the whole application locks up, in some cases for many minutes, with no way to cancel. Right now the renderer is required to run in the UI thread - even if it's a "headless" rendering such as in PNG export. That seems odd to me.
Any thoughts on this subject? Maybe I should add it as a blueprint in launchpad.
Yes, writing up some detailed thoughts on this would be a great step.
You might also find it worthwhile to browse back through the archives for this list at gmane.org (or via google) to see if you can find previous instances where we've talked about this. (Maybe we discussed it only on IRC though... don't remember.) It would be great to have a detailed summary and plan to point to for this work.
Bryce