Skip to content

2.2.0 - Massive performance boost and memory fixes.

Latest
Compare
Choose a tag to compare
@curthard89 curthard89 released this 05 Jan 17:19
· 271 commits to master since this release

This build vastly improves path data parsing by about 8x, how you ask? The slowest parts of parsing command data was allocation of memory and then memory copying to generate floats, we now use one memory buffer instance per SVG and keep reusing the same one over and over again, which greatly reduces memory and shoots performance through the root. The other slowdown was atof or strtod_l, converting a char * over to a float, we now have a custom implementation which is almost 4x faster. This can all be found inside the new IJSVGCommandParser.h/m class.

Rendering is now faster due to fixing a bug that resolved in memory leaks (IJSVG never leaked the memory, we just had fixes), we used to use CATransactionLock/Commit to get around threading issues and the leak, but now, after hours of pain, setting the content of IJSVGLayer to nil in dealloc fixes the memory leak on background threads, thus making rendering perform better as transaction does not need locking.

We have also rewritten the exporting path data processing so that the paths are more compressed and where possible, white space is removed between floating points that are either decimal or use exponents. This greatly reduces the file size when complicated SVG are exported.

This also fixes an issue where arc command were not being parsed correctly due to exported SVG's having their sweeping flags compressed together and being read as one whole float instead of flags. Each command now supports a IJSVGPathDataSequence which can be supplied when being parsed which tells the parser how to treat and read certain floats in when parsing command data, these consist of kIJSVGPathDataSequenceTypeFloat and kIJSVGPathDataSequenceTypeFlag.