ProjectMirador / mirador

An open-source, web-based 'multi-up' viewer that supports zoom-pan-rotate functionality, ability to display/compare simple images, and images with annotations.
https://projectmirador.org
Apache License 2.0
556 stars 256 forks source link

All elements of a Choice annotation are rendered simultaneously #3585

Open irv opened 1 year ago

irv commented 1 year ago

When viewing a manifest that contains a canvas with a Choice annotation, Mirador will flatten the annotations and vacuum up all the image service annotations, passing them to open sea dragon and rendering them, even if there's no interaction with the layers view. If I have understood the code correctly, this seems to happen here: https://github.com/ProjectMirador/mirador/blob/5ca33205bf9bac636ba5ef0faf820f58c0d9751d/src/lib/MiradorCanvas.js#L76-L77

This means if the user does open the layers view, it's very smooth when toggling the display of each layer because the tiles are loaded. But for instances where we have more then 2 layers, this is a lot of wasted image requests, especially if the user never interacts with them.

You can see this using just the cookbook recipe: https://projectmirador.org/embed/?iiif-content=https://iiif.io/api/cookbook/recipe/0033-choice/manifest.json

And looking at the network requests where it loads tiles for both the natural and x-ray version without any user interaction:

image

And this is obviously made worse with a larger viewport, as more tiles are requested at once...

I think a better approach would be to load the thumbnails for each Choice annotation, and then add the first element only (as this is supposed to be the default. See https://www.w3.org/TR/annotation-model/#choice-between-bodies). When interacting with the layers view, the additional tile sources can then be passed to open sea dragon.

irv commented 1 year ago

We have an actual manifest in use which illustrates this, that is not just the cookbook.

Note that we use content negotiation, and only the presentation API V3 version has choice annotations.

https://iiif.bodleian.ox.ac.uk/iiif/manifest/1fc3f35d-bbb5-4524-8fbe-a5bcb5468be2.json