slide-drive icon indicating copy to clipboard operation
slide-drive copied to clipboard

Optimize SVG Importing

Open banksJeremy opened this issue 12 years ago • 4 comments

SVGs are slow slow _slow_. Importing large presentation is painfully slow. It needs to be made faster, and possibly made somewhat async so the UI doesn't freeze while it's importing.

Other SVG operations could be sped up as well. One possibility I liked was rasterizing SVGs on load in Firefox, so it doesn't overexert itself re-rendering them whenever anything changes, but apparently Chrome and Firefox haven't figured out how to handle SVGs securely and mark the canvas as "tainted" when they interact with SVGs, making this apparently impossible.

banksJeremy avatar May 14 '12 15:05 banksJeremy

Is there a way where we can prioritize loading? So we load the current slide, then the next slide, and then continue from there. If we can make it so we limit it to loading 1 slide at a time I think it would prevent us from having the UI freezing issue. I wonder if there is some dependancy loading libraries out there that we could utilize.

dseif avatar May 14 '12 15:05 dseif

Okay, I've got that working. I just setInterval and processed them one at a time. There's nothing expecting the slides to be available instantly that can be broken by adding them one-at-a-time. This looks pretty good.

The drag and drop handling currently depends on a patch in my butter branch. How this ends up being implemented upstream may affect our options here. See this Butter issue for details.

banksJeremy avatar May 14 '12 17:05 banksJeremy

Is there any way we can do this with callbacks instead of a setInterval??

dseif avatar May 14 '12 18:05 dseif

If we just use a series of callbacks then we'll never yield to the UI thread and we won't have gained anything. I think we need to use setInterval/setCallback because there aren't any async operations for us to respond to.

If each slide were in a different file, we could rely on the fact that files are read asynchronously: if we would wait to open each file until the previous one is finished, we could yield to the UI while the file's contents are loaded. Unfortunately that's not the case.

banksJeremy avatar May 14 '12 18:05 banksJeremy