Skip to content

Conversation

@mrxz
Copy link
Collaborator

@mrxz mrxz commented Sep 25, 2025

This PR replaces the usage of fflate with DecompressionStream for decompressing .spz files. This lets the browser handle the decompression, yielding a noticeable improvement in loading times (measured in Chromium):

Example Main DecompressionStream
Hello World 341 ms 177 ms -48%
WebXR 404 ms 206 ms -49%
Splat Transition 284 ms 127 ms -55%
378 ms 195 ms -48%
837 ms 470 ms -44%

⚠️ The Compression Streams API is inherently asynchronous, but Gunzip from fflate allowed for synchronous usage. This means that the interface for the SpzReader had to change. Since it's part of the exported symbols, this impacts all user-code that use SpzReader directly.

Before

const spz = new SpzReader({ fileBytes });
const numSplats = spz.numSplats;
// ... (allocate resources)
spz.parseSplats( ... )

After

const spz = new SpzReader({ fileBytes });
await spz.parseHeader(); // Required to access properties like `numSplats`
const numSplats = spz.numSplats;
// ... (allocate resources)
await spz.parseSplats( ... )

@dmarcos
Copy link
Contributor

dmarcos commented Sep 25, 2025

thanks

@dmarcos dmarcos merged commit c6bb49d into sparkjsdev:main Sep 25, 2025
2 checks passed
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