Skip to content

Make the compression_mode argument of compression related API required #12496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
beicause opened this issue May 25, 2025 · 0 comments
Open
Labels
breaks compat Proposal will inevitably break compatibility topic:core

Comments

@beicause
Copy link

Describe the project you are working on

Godot

Describe the problem or limitation you are having in your project

The compression_mode argument of PackedByteArray.compress/decompress/decompress_dynamic and FileAccess.open_compressed is 0 (COMPRESSION_FASTLZ) by default.

This is less than ideal, as it is necessary to ensure the compression methods match during compression and decompression. Generally, you should always explicitly set the compression method rather than relying on default values.


PackedByteArray decompress_dynamic(max_output_size: int, compression_mode: int = 0) const 🔗

Returns a new PackedByteArray with the data decompressed. Set the compression mode using one of CompressionMode's constants. This method only accepts brotli, gzip, and deflate compression modes.

decompress_dynamic does not support fastlz, so the default value makes no sense.

In addition, fastlz is a relatively old compression and doesn't have much advantages compared to modern compression such as zstd or lz4. https://github.com/inikep/lzbench/blob/master/doc/lzbench20_sorted.md. Setting it as the default value seems to imply that we recommend using it.

Related C# binding: godotengine/godot#106008

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Make the compression_mode argument required.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Modify the method binding of PackedByteArray and FileAccess to make the compression_mode argument required, but this breaks compatibility.

If this enhancement will not be used often, can it be worked around with a few lines of script?

N/A

Is there a reason why this should be core and not an add-on in the asset library?

N/A

@Calinou Calinou added topic:core breaks compat Proposal will inevitably break compatibility labels May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaks compat Proposal will inevitably break compatibility topic:core
Projects
None yet
Development

No branches or pull requests

2 participants