These are chat archives for openseadragon/openseadragon

19th
Aug 2015
Ian Gilman
@iangilman
Aug 19 2015 00:41
@TravisH84 cool. Do you have a lot of images to do? If so, it might be worth getting up to speed with VIPS.
LarissaSmith
@LarissaSmith
Aug 19 2015 22:06
I have been looking at ways to optimize world._arrange when there are a large number of items in the world. For each item that world._arrange repositions, it raises a bounds-change event on the tiledImage that calls world._figureSizes, which loops through every item in the world and performs some fairly hefty calculations. For a world with above 1000 items, this was getting to be expensive. By canceling all of the bounds-change events in world._arrange and calling _figureSizes only once at the end of the loop, I changed the time it took to rearrange 1000 images from > 2 seconds to almost instantaneous. Then by reducing calls to world._arrange in addTiledImage, I cut the time it took to add 1000 items to the world by half. I'm eager to make these optimizations for our app, but I suppose that I can't just cancel all the bounds-change events in world._arrange, especially if I want to push this change. Any comments? Maybe _figureSizes could be called based on an internal state?
Ian Gilman
@iangilman
Aug 19 2015 22:11
@LarissaSmith Nice! Yeah, I guess we only need it once at the end of arrange, right?
We just need to also support those events for one off movements.
Btw, arrange is just meant to provide some basic options...the assumption is if you're doing anything more complicated, you'll write your own arrangement function.
That said, having it more optimized would be wonderful!
But yeah, perhaps for your use, not using collectionMode and instead controlling when you call arrange would be good.
Ian Gilman
@iangilman
Aug 19 2015 22:17
I think we still need all of the bounds-change events to fire, but maybe we can have a flag on World that tells it to not figureSizes during the arrange (or during an external arrange)
LarissaSmith
@LarissaSmith
Aug 19 2015 22:19
@iangilman Correct. It's checking for changes to the world bounds and content size or content factor, but I think those can be calculated fine at the end of _arrange.
Ian Gilman
@iangilman
Aug 19 2015 22:20
Definitely.
LarissaSmith
@LarissaSmith
Aug 19 2015 22:20
I've kept the possibility of writing a custom arrange in mind, but so far we haven't needed to. I think it would run into the same performance issue with bounds-change.
Ian Gilman
@iangilman
Aug 19 2015 22:21
Indeed. You certainly don't need to if you don't need more options.
So if World had something like setAutoRefigureSizes() that you could pass true or false into, that would work for arrange and also be available for others.
LarissaSmith
@LarissaSmith
Aug 19 2015 22:23
Sounds good to me.
Ian Gilman
@iangilman
Aug 19 2015 22:24
Cool. I love that you're digging into this! It's meant to support thousands of items, but I haven't really pushed it like you are.
LarissaSmith
@LarissaSmith
Aug 19 2015 22:29
Thanks! It's a fun project.
Ian Gilman
@iangilman
Aug 19 2015 22:33
:)