spstreets / gtfs_manager

A GUI for viewing and editing GTFS data
MIT License
30 stars 3 forks source link

Improve performance of map #15

Closed maxwell8888 closed 2 years ago

maxwell8888 commented 2 years ago

The map currently draws all the routes on the map with every paint, which is slow, and doesn't use any form of caching. This is exacerbated by the fact the a bug/quirk in the Either widget (https://github.com/linebender/druid/issues/2205) means there is often a full screen refresh, and thus map paint, even when not interacting with the map.

Initially this will likely be solved by drawing the lines once, saving to a bitmap, and then reusing this bitmap on subsequent paints, only drawing individual for hover/selection hightlighting, and recreating the bitmap when routes are shown/hidden. See https://xi.zulipchat.com/#narrow/stream/259397-piet/topic/Apply.20transform.20to.20GPU.20buffer

Hopefully in the future it will be possible to cache the paths themselves and apply transformations directly to them, and avoid having to use a bitmap.

Related

https://github.com/linebender/druid/issues/1889

Robinlovelace commented 2 years ago

Definitely an important one, are there people in the community you can ask directly for support on this? @dabreegster may be able to help directly or link-up people, although maybe it's quite specific to Druid?

dabreegster commented 2 years ago

I think it's a bit too Druid specific. If you can access raw OpenGL / similar layers and do basic shaders, my advice is to upload polygons + colors to the GPU once, and then make a shader apply translations and zooming constantly.

maxwell8888 commented 2 years ago

I've already spent a lot of time looking into this, asking on the Druid forum, etc. I'm pretty sure this is the best approach that Druid allows at the moment, but I'm pretty sure it will do the job, and if it doesn't there are other things we can do to avoid the need for interactive tracking and zooming, which would effectively make the issue of slow rendering obsolete anyway.

maxwell8888 commented 2 years ago

Using bitmap caching without tiling when the map is zoomed out, and drawing everything each frame when zoomed in. Currently this is transition is just hardcoded at around 10x zoom, but will eventually instead replace with some heurisic using the latlong size of the map and/or density of paths and stops.