feat(decompressor): add Brotli decoder for compression byte 1#125
Closed
infinia-yzl wants to merge 1 commit into
Closed
feat(decompressor): add Brotli decoder for compression byte 1#125infinia-yzl wants to merge 1 commit into
infinia-yzl wants to merge 1 commit into
Conversation
The wire-format compression byte 1 (Brotli) currently logs "Brotli compression not supported!" and drops the payload. Wire it up to Godot's built-in PackedByteArray.decompress_dynamic with FileAccess.COMPRESSION_BROTLI. DataDecompressor.decompress_brotli_packet is a one-shot non-streaming call (Godot has no StreamPeerBrotli equivalent), capped at 64 MiB output. Larger payloads would already be rejected by the WebSocket layer's inbound_buffer_size before reaching here. Failure mode (empty PackedByteArray) matches decompress_packet so the existing _decompress_and_parse contract is preserved. Verified end-to-end via unit tests in a downstream project: short payload round-trip, highly-redundant 5 KB payload round-trip, empty input → empty output, garbage input → empty + no crash. Brotli fixtures are generated offline (Godot has no Brotli encoder, only a decoder).
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.
Summary
_decompress_and_parsecurrentlyprinterrs on wire-format compression byte 1 (Brotli) and drops the payload. SpacetimeDB 2.2 can negotiate Brotli compression (clockworklabs/SpacetimeDB#4561 server-side support). Wire byte 1 to a newDataDecompressor.decompress_brotli_packetthat uses Godot's built-inPackedByteArray.decompress_dynamicwithFileAccess.COMPRESSION_BROTLI.Why one-shot, not streaming
Godot ships
StreamPeerGZIPbut noStreamPeerBrotli, so streaming decoding isn't an option here. The non-streamingdecompress_dynamicrequires a hard cap on output size — I setBROTLI_MAX_DECOMPRESSED_BYTES = 64 MiB, which comfortably covers any single-frame BSATN payload from a SpacetimeDB server. Larger payloads would already be refused by the WebSocket layer'sinbound_buffer_sizebefore reaching here.Failure mode
Empty
PackedByteArrayon error — matches the existingdecompress_packetcontract so_decompress_and_parsecallers don't need to change.Verification
End-to-end via unit tests in a downstream project:
Test plan
_decompress_and_parsematches case 1 cleanly with the new decoderRelated
🤖 Generated with Claude Code