Repository navigation
fix: normalize VTKHDF long arrays to fixed width for the wasm client - #169
Merged
Merged
Conversation
margalva
approved these changes
Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Addresses #122
Description
This is a temporary workaround for an upstream issue when loading VTKHDF files on macOS and Linux.
load_stateinto an empty scene leaves the canvas empty and vtkWebAssembly throwsstd::bad_alloc; however, it works as expected on Windows. See screenshot below.vtkObjectManagerserializesvtkLongArray/vtkUnsignedLongArrayby class name only, without an element width.longis 8 bytes on an LP64 server and 4 bytes in the wasm32 client, so the client lays a 4-byte array over an 8-byte buffer (measured: connectivity[0,1,2]arrives as[0,0,1],GetCellSize(0) == 0).vtkHDFReaderreturns 64-bit integers, including cell connectivity/offsets, asvtkLongArrayon LP64. Polydata reaches the mapper by shallow copy, so the served class isvtkLongArray.vtkTypeInt64Array/vtkTypeUInt64Array) right aftervtkHDFReaderreads a file, infile_to_dataset. Nothing else is converted.Symptom when loading a VTKHDF file:
Choices and tradeoffs.
.vtkhdffiles opened by path..vtp/.vtm/.vtureads and in-memory datasets are not touched.file_to_datasetalready owns, so no user-held object changes class. A conversion atadd_datasetwas rejected for that reason.longarrays (for example numpyint64vianumpy_to_vtkon Linux) are still affected by the upstream defect. Validating/rejecting them is deferred.vtkTypeInt64Array, notvtkCellArray.ConvertTo64BitStorage(). It matches the class the working VTP path serves and also covers point/cell/field data;ConvertTo64BitStoragecovers cell arrays only.vtkLongArray, so the helper is a no-op there.vtkFieldDatahas no replace-in-place, so arrays from the first converted one onward are removed and re-appended in order; active-attribute roles are restored.Removal. Delete
client_dataset_normalizer.py, its import and theif is_hdf:block infile_to_dataset.py,tests/unit/vtk/io/test_client_dataset_normalizer.py, andtest_file_to_dataset_normalizes_long_arrays_only_for_vtkhdfonce the VTK version Visor depends on serializes platform-width arrays with a fixed element width. The module docstring and the call site say the same.