Open johnblommers opened 7 years ago
johnblommers - Thanks for your note and link to an interesting SVG file, which contained many "use" elements.
I found the main slowdown to be during the initial loading of the pattern.svg document. It was taking 20 seconds, which was clearly too long.
I found this line in MacSVGDocumentWindowController.m, at line 1065 -
[self.xmlOutlineController expandAllNodes];
After that line was disabled, your pattern.svg document loaded much faster. In the user interface, it means that the hierarchical outline view of the SVG document will be fully collapsed when the document is open.
I'll commit a couple of line changes to the repository and do further testing. The expandAllNodes call when the document is opened might become a conditional operation depending on the number of elements the SVG document. It will likely be included in the next release.
The rendering speed in this SVG editing application will always be slower than in a web browser. Although this project is moving to Swift language, that probably won't affect the rendering speed much.
Some of the slower rendering is due to unnecessary multiple updates of the web view and other views. Those can be fixed in the future by deferring screen updates to the end of the event cycle.
Another possibility for faster performance is to fork WebKit and restore the old Objective-C APIs for SVG which Apple removed a few years ago, or at least exposing some WebCore properties and functions for custom usage. But maintaining a separate fork of WebKit would be a big project. Currently, macSVG uses the standard WebKit framework in macOS.
You could improve performance by moving to WebKit 2 / WKWebView. I wouldn't bet too much on the synchronous WebKit 1 API as it's very likely going to be deprecated in future.
Unzip and open the attached file
pattern.svg.zip
with macSVG and you will observe how slow the rendering engine is. Dropping the same file onto the Chrome web browser renders the image almost instantly. Hopefully the migration to Swift and perhaps an eye to the SVG rendering engine will provide a much-needed rendering boost. As it stands right now there is considerable time spent in the BBOD. pattern.svg.zip