silx-kit / h5web

React components for data visualization and exploration
https://h5web.panosc.eu/
MIT License
165 stars 17 forks source link

Implement `H5wasmLocalFileProvider` #1604

Closed axelboc closed 2 months ago

axelboc commented 3 months ago

Fix #1582 🎉

This is a first implementation of H5WasmLocalFileProvider, a provider that allows random access to local HDF5 files with h5wasm in a web worker, thus hopefully removing the ~2 GB file size limit inherent to the original, buffer-based H5WasmProvider.

H5WasmProvider remains available and unchanged. The demo just picks the right provider based on whether the user opens/drops a local file or enters the URL of a remote file.

The web worker is initialised with type: 'module' which limits browser support (FF >= 114). I'll have to investigate a way to detect support in consumer applications like myHDF5 to allow falling back to H5WasmProvider on unsupported browsers.

Comlink provides an RPC abstraction to interact with the web worker. The worker exposes a number of async methods to open a file, get an entity's metadata, and read dataset and attribute values, in line with the DataProviderApi requirements. Every call to h5wasm is done synchronously inside the worker, which considerably simplifies its implementation and the implementation of the provider's API class. The downside is that the worker cannot be extracted into a generic package (as was previously the plan with h5wasm-worker).

Next step will be to add the remaining provider features (compression plugins, export ...)