biigle / annotations

:m: BIIGLE module to create, edit and explore image annotations
0 stars 1 forks source link

Better performance for lots of annotations #50

Closed mzur closed 7 years ago

mzur commented 7 years ago

Improve the performance for lots (>400) of complex (free hand polygon) annotations. Due to the filtering mechanism all annotations are redrawn on every change. Improve this so only the changed annotations are redrawn.

mzur commented 7 years ago

The critical performance issues when adding and removing annotations are fixed now.

Map interactions (zooming, panning) have improved for large numbers of annotations because of the dynamic rendering of the annotation layer. It can be even faster if a simpler feature style would be used. Currently it's the white outline and the colored stroke, each of which needs to be drawn separately. If we only take the colored stroke, for example, rendering is much faster. But I've decided not to change the style (not even just for large numbers of annotations) for better consistency (users should be trained to recognize the annotation style) and because zooming and panning is not a very critical task.

One issue that remains is switching from an image with lots of annotations to another or to apply an annotation filter that removes lots of annotations. The annotationSource.clear() function is very slow for lots of annotations and I had to wait up to 15 s with my edge case of >600 freehand polygons until the map became responsive again. I'm not sure if we can do anything about it. We probably have to debug OpenLayers to see what exactly takes that much time. Drawing the 600 polygons is much faster than removing them.

mzur commented 7 years ago

The bad performance is caused by the modify interaction which updates it's internal datastructure for each feature that is removed. If the modify interaction is removed, switching images is fast again. Here is a call stack:

screenshot from 2016-12-12 16-42-35

Disabling the interaction does not work because it handles the events in the background anyway. It has no public methods that could be useful.