parseSVGElement() very slow on Snow Leopard

I have an older OSX universal binary, based on Juce 1.42, originally compiled on 10.4.11 Tiger with XCode 2.5, and it’s running just fine on older Intel macs.

However, when running that exact same binary on the exact same hardware, but this time using Snow Leopard 10.6.3, it exhibits an extreme slowness during execution of the Juce parseSVGElement() function with large SVGs. I mean, something that took 700ms in the past now takes in excess of 20 seconds. All the obvious things have been checked (no debug build, optimizations enabled, etc).

I know I should move to the tip & XCode 3.x, and I will eventually of course, but I wondered whether this is a known issue?
parseSVGElement() mostly looks like code that doesn’t touch the OS, so where on earth could that huge performance difference come from?

That really is very very odd - like you say, SVG parsing has always been 100% pure c++, and doesn’t make any OS calls at all. I suspect there must be some other non-obvious reason for it. If the tip doesn’t perform quickly, be sure to let me know.

yeah, it baffled me too :shock:
I’ll try to repro it with the tip and let you know what I find out

BTW the current tip requires XCode 3.2 or higher to compile?

good news! compiled a small sample app with the tip and the problem seems to be gone. So tip, here I come :slight_smile:

a quick related question though (need a short-term workaround before completing the migration to the tip):

As the problem made parsing large SVGs into drawables very expensive in time consumption, I wondered whether I could cache a pointer to the drawable and reuse it.
So the question is: when drawing the the old-style Drawable class (before they became Components), does this modify internal state of that Drawable?
Or in other words: could I cache static pointers to a Drawable and draw that same single Drawable instance from multiple threads and onto multiple graphics contexts concurrently?

For backwards-compatibility I made sure you could still draw them like they used to work, so you can do it either way, really. But if you do need to create multiple copies, it’s much quicker to just parse the SVG once and then clone than to keep re-parsing the SVG to create them.