Skip to content

Commit

Permalink
Update NGPre tile source WASM code
Browse files Browse the repository at this point in the history
This update adds Google Cloud storge API rewrite improvements.
  • Loading branch information
tomka committed Jan 24, 2025
1 parent 1e8778d commit c43aa14
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 32 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ Data sources:
defined in the stack meta data in the admin view, e.g. `{"voxelOffset":
[-3072, -3072, 0]}`.

- Neuroglancer Precomputed URLs that start with `gs://` are rewritten on the fly
to use Google Cloud storage get API requess, improving CORS support.

- A second new tile source is available: CloudVolume based tiles, generated by
the back-end. While slow for many users, it is a convenient way of make
neuroglancer volumes available to CATMAID if they aren't supported by the
Expand Down
57 changes: 26 additions & 31 deletions django/applications/catmaid/static/libs/ngpre-wasm/ngpre_wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,28 +227,6 @@ let wasm_bindgen;
return className;
}

function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
}

let cachedBigUint64ArrayMemory0 = null;

function getBigUint64ArrayMemory0() {
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
}
return cachedBigUint64ArrayMemory0;
}

function passArray64ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 8, 8) >>> 0;
getBigUint64ArrayMemory0().set(arg, ptr / 8);
WASM_VECTOR_LEN = arg.length;
return ptr;
}

let cachedUint32ArrayMemory0 = null;

function getUint32ArrayMemory0() {
Expand All @@ -263,6 +241,15 @@ let wasm_bindgen;
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
}

let cachedBigUint64ArrayMemory0 = null;

function getBigUint64ArrayMemory0() {
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
}
return cachedBigUint64ArrayMemory0;
}

function getArrayU64FromWasm0(ptr, len) {
ptr = ptr >>> 0;
return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
Expand Down Expand Up @@ -371,6 +358,19 @@ let wasm_bindgen;
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
}

function _assertClass(instance, klass) {
if (!(instance instanceof klass)) {
throw new Error(`expected instance of ${klass.name}`);
}
}

function passArray64ToWasm0(arg, malloc) {
const ptr = malloc(arg.length * 8, 8) >>> 0;
getBigUint64ArrayMemory0().set(arg, ptr / 8);
WASM_VECTOR_LEN = arg.length;
return ptr;
}

let stack_pointer = 128;

function addBorrowedObject(obj) {
Expand All @@ -382,12 +382,10 @@ let wasm_bindgen;
wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hba9c4d05d94bb2f6(arg0, arg1, addHeapObject(arg2));
}

function __wbg_adapter_255(arg0, arg1, arg2, arg3) {
function __wbg_adapter_253(arg0, arg1, arg2, arg3) {
wasm.wasm_bindgen__convert__closures__invoke2_mut__ha4add01b7784d4e4(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}

const __wbindgen_enum_ReferrerPolicy = ["", "no-referrer", "no-referrer-when-downgrade", "origin", "origin-when-cross-origin", "unsafe-url", "same-origin", "strict-origin", "strict-origin-when-cross-origin"];

const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];

const DatasetAttributesFinalization = (typeof FinalizationRegistry === 'undefined')
Expand Down Expand Up @@ -2140,7 +2138,7 @@ let wasm_bindgen;
const a = state0.a;
state0.a = 0;
try {
return __wbg_adapter_255(a, state0.b, arg0, arg1);
return __wbg_adapter_253(a, state0.b, arg0, arg1);
} finally {
state0.a = a;
}
Expand Down Expand Up @@ -2232,9 +2230,6 @@ let wasm_bindgen;
imports.wbg.__wbg_setmode_cd03637eb7da01e0 = function(arg0, arg1) {
getObject(arg0).mode = __wbindgen_enum_RequestMode[arg1];
};
imports.wbg.__wbg_setreferrerpolicy_aac7a6a625ee4900 = function(arg0, arg1) {
getObject(arg0).referrerPolicy = __wbindgen_enum_ReferrerPolicy[arg1];
};
imports.wbg.__wbg_static_accessor_GLOBAL_0be7472e492ad3e3 = function() {
const ret = typeof global === 'undefined' ? null : global;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
Expand Down Expand Up @@ -2353,8 +2348,8 @@ let wasm_bindgen;
const ret = false;
return ret;
};
imports.wbg.__wbindgen_closure_wrapper1323 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 264, __wbg_adapter_54);
imports.wbg.__wbindgen_closure_wrapper1326 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 266, __wbg_adapter_54);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
Expand Down
Binary file not shown.
11 changes: 10 additions & 1 deletion sphinx-doc/source/tile_sources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ Tile source types are listed by the enumeration integer ID referenced by
components. It should end in a path component specifying the ordered
dimensions from which image data should be sliced, separated by underscores.
For example, ``2_1_0`` will slices chunk dimensions 2, 1, and 0 as the x, y,
and z stack dimensions, respectively.
and z stack dimensions, respectively. Make sure, the path has no trailing
slash.

This tile source will also look for a path component ending in ``/info`` to
use as the dataset root directory. If it does not find such a component, it will
Expand All @@ -417,6 +418,14 @@ Tile source types are listed by the enumeration integer ID referenced by
is ``(-3072, -3072, 0)``, then the metadata of the CATMAID stack should look
like this: ``{"voxelOffset": [-3072, -3072, 0]}``.

If the ``gs://`` protocol is used like in the example above, each final
request path is rewritten in order to use the `get method
<https://cloud.google.com/storage/docs/json_api/v1/objects/get>`_ for their
Cloud objects. Otherwise, no data can be loaded due to CORS restrictions. A
rewritten URL looks like this (requesting the ``/info`` file)::

https://www.googleapis.com/storage/v1/b/neuroglancer/o/pinky100_v0%2Fson_of_alignment_v15_rechunked%2Finfo?alt=media

Backend Representation
----------------------

Expand Down

0 comments on commit c43aa14

Please sign in to comment.