Skip to content

chore -cached loading (V3 omezarr support) step one#205

Merged
froyo-np merged 10 commits intomainfrom
noah/cached-store-first-step
Oct 13, 2025
Merged

chore -cached loading (V3 omezarr support) step one#205
froyo-np merged 10 commits intomainfrom
noah/cached-store-first-step

Conversation

@froyo-np
Copy link
Collaborator

@froyo-np froyo-np commented Oct 13, 2025

Cached Fetching via zarrita store

What

  • caches fetches for byte-ranges, which our test-browsers seem unwilling to do
  • runs those fetches on a pool of workers
  • hides all the above from existing rendering code via a 'decoder' passed to the renderer
  • [ ]

How

  • Cherry-picked worker-pool, worker implementation, and priority-based data store from @Jarbuckle 's excellent work
  • Added the cache-injected decoder - see cache-lower.ts

Known issues

  • the blosc decompression still happens on the main thread, due to unforseen complications with how zarrita handles sharded data.
  • fetches for byte-ranges are never cancelled, due to what seems to be a mistake in how zarrita handles sharded fetches...
  • we still dont know how to ship a web-worker whole-sale from an imported package we build with vite, so for now, the worker has to be created in a somewhat awkward way by the user of this work, (in our case, the demo).

Screenshots

This section is optional if there are no visible changes

  • If possible add screenshots of the visible additions in the UI.
  • If there are changes in the UI, add Before and After Screenshots for quick overview.
  • If there was a Figma design, add a link to that here as well.
  • Hint : Drag and Drop any images you want to add to the PR. Also you can create a gif of an interactive version and add that!

PR Checklist

  • Is your PR title following our conventional commit naming recommendations?
  • Have you filled in the PR Description Template?
  • Is your branch up to date with the latest in main?
  • Do the CI checks pass successfully?
  • Have you smoke tested the example applications?
  • Did you check that the changes meet accessibility standards?
  • Have you tested the application on these browsers?
    • Chrome (Fully supported)
    • Firefox (Major bug fixes supported)
    • Safari (Major bug fixes supported)

import { logger } from '@alleninstitute/vis-core';
import { ZarrFetchStore, type CachingMultithreadedFetchStoreOptions } from './cached-loading/store';

export function decoderFactory(url: string, workerModule: URL, options?: CachingMultithreadedFetchStoreOptions) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is the only (interesting) non-cherry-picked change here - the rest is directly plucked from #203

@froyo-np froyo-np requested a review from Jarbuckle October 13, 2025 21:37
};
useEffect(() => {
if (cnvs.current && server && !renderer) {
const { decoder } = decoderFactory(getResourceUrl(props.res), WORKERS);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here is where we create the decoder - we create it when we are about to load the data... now that i'm looking at this, it wont ever re-create the decoder (like say, when you want to view a different file), but thats been an issue forever in this demo, so maybe its fine

Copy link
Contributor

@Jarbuckle Jarbuckle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple small things!

};
useEffect(() => {
if (cnvs.current && server && !renderer) {
const { decoder } = decoderFactory(getResourceUrl(props.res), WORKERS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we concerned at all about the prospect of useEffect() calls happening multiple times and producing a lot of workers? Will the old workers be discarded by the GC?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent question - yes we should be concerned... i dont think that is happening in this very canned demo... but we should consider preventing that scenario!

as for workers being GC'd - I dont think that happens... workers have to be killed externally with terminate() I think. I'll see about how we would do that in a sane way....

@Jarbuckle
Copy link
Contributor

Set it up locally and tested, working just great!

@froyo-np froyo-np marked this pull request as ready for review October 13, 2025 22:33
@froyo-np froyo-np requested a review from a team as a code owner October 13, 2025 22:33
Copy link
Contributor

@Jarbuckle Jarbuckle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Works well, seems to cover what we need it to cover! Woo!

@Jarbuckle Jarbuckle self-requested a review October 13, 2025 22:50
Copy link
Contributor

@Jarbuckle Jarbuckle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hold that -- something's not quite working right: I'm trying to view the example OME-Zarr in the Priority Cache example page and it's not loading 😟

Copy link
Contributor

@Jarbuckle Jarbuckle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works!

@froyo-np froyo-np enabled auto-merge (squash) October 13, 2025 23:40
@froyo-np froyo-np merged commit 0552540 into main Oct 13, 2025
5 checks passed
@froyo-np froyo-np deleted the noah/cached-store-first-step branch October 13, 2025 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants