allen-cell-animated / volume-viewer

https://allen-cell-animated.github.io/volume-viewer/
Other
90 stars 7 forks source link

Load single slices at higher resolution #163

Closed frasercl closed 9 months ago

frasercl commented 10 months ago

Resolves #157: If a 3d volume is loaded, the user switches to z-slice mode, and a higher resolution level is available to load, reload at that higher resolution.

This is accomplished using the loadDims method on IVolumeLoader (unused until now), which loads the dimensions of a volume without loading any data. I made the following changes to make loadDims a good solution to this issue:

I also got rid of the scene property of LoadSpec, given that the only loader that supports scenes right now (OmeZarrLoader) must be bound to a single scene on construction.

ShrimpCryptid commented 10 months ago

I tried running this to test it, and I ran into an error?

Repro:

  1. Run the project (npm run start)
  2. Switch to OME Zarr (NucMorph)
  3. Switch to Z viewer
    Uncaught Runtime Errors:
    ERROR
    chunk request cancelled
    at handleError (http://localhost:9020/volume-viewer-ui.bundle.js:25109:58)
    at http://localhost:9020/volume-viewer-ui.bundle.js:25132:7
    ERROR
    chunk request cancelled
    at handleError (http://localhost:9020/volume-viewer-ui.bundle.js:25109:58)
    at http://localhost:9020/volume-viewer-ui.bundle.js:25132:7
    ERROR
    chunk request cancelled
    at handleError (http://localhost:9020/volume-viewer-ui.bundle.js:25109:58)
    at http://localhost:9020/volume-viewer-ui.bundle.js:25132:7

It's possible this is related to the Vast outage today. Will check again later.

ShrimpCryptid commented 10 months ago

I tried running this to test it, and I ran into an error?

Repro:

  1. Run the project (npm run start)
  2. Switch to OME Zarr (NucMorph)
  3. Switch to Z viewer
Uncaught Runtime Errors:
ERROR
chunk request cancelled
    at handleError (http://localhost:9020/volume-viewer-ui.bundle.js:25109:58)
    at http://localhost:9020/volume-viewer-ui.bundle.js:25132:7
ERROR
chunk request cancelled
    at handleError (http://localhost:9020/volume-viewer-ui.bundle.js:25109:58)
    at http://localhost:9020/volume-viewer-ui.bundle.js:25132:7
ERROR
chunk request cancelled
    at handleError (http://localhost:9020/volume-viewer-ui.bundle.js:25109:58)
    at http://localhost:9020/volume-viewer-ui.bundle.js:25132:7

It's possible this is related to the Vast outage today. Will check again later.

Still getting this bug today.

This is all I'm getting from the console:

index.ts:872 currentVol with name AICS-12_881 is loaded
index.ts:872 currentVol with name P13-C4 is loaded
localhost/:1 Uncaught (in promise) chunk request cancelled
index.ts:872 currentVol with name P13-C4 is loaded
toloudis commented 10 months ago

If I have any coding time today I'll try to take a look at this error message. This is an important change to get in soon.

toloudis commented 9 months ago

The error here is indeed an uncaught promise exception that occurs when we cancel a request. This pull request : https://github.com/gzuidhof/zarr.js/pull/145 actually seems to fix the issue. (also see https://github.com/gzuidhof/zarr.js/issues/140) The problem seems to be that our promises get stuck in the zarr.js plumbing because of their internal logic in between our proxy store's SmartStoreWrapper.getRaw and the resulting multiple calls to the true store's getItem.

You can see some hints of this by changing return this.requestQueue.addRequest(key, () => this.getAndCacheItem(item, key, opts)); to

return this.requestQueue
        .addRequest(key, () => this.getAndCacheItem(item, key, opts))
        .catch((e) => {
          if (e !== CHUNK_REQUEST_CANCEL_REASON) {
            throw e; // this will be unhandled!!!
          }
          // if cancelled, we still need to return an arraybuffer of the expected size,
          // or else handle this one - returning this buffer still breaks things.
          return new ArrayBuffer(0);
        });

Another way of saying this is: We call getRaw to fetch some data. The getRaw call is converted into many getItem calls by zarr.js's internals. We are overriding getItem in our SmartStoreWrapper. Each getItem becomes a cancellable request promise generated by our RequestQueue. These getItem requests are per-chunk, and are not propagated back out of the SmartStoreWrapper when getRaw finishes.