dseif / slide-drive

Slideshow using audio/video to drive content
45 stars 9 forks source link

Optimize SVG Importing #21

Open banksJeremy opened 12 years ago

banksJeremy commented 12 years ago

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.

dseif commented 12 years ago

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.

banksJeremy commented 12 years ago

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.

dseif commented 12 years ago

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

banksJeremy commented 12 years ago

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.