Skip to content

πŸ›πŸ§‘β€πŸ’» - Replace deprecated ZSTDgetDecompressedSize with ZSTDgetFrameContentSizeΒ #103

@efraespada

Description

@efraespada

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Zstandard macOS

Which platforms are affected?

macOS

Description

The plugin uses the deprecated zstd API ZSTD_getDecompressedSize() to obtain the decompressed size before calling ZSTD_decompress(). This function has been removed (or is being removed) in newer environments (e.g. macOS 26+), and the zstd documentation recommends using ZSTD_getFrameContentSize() instead.

Proposed solution

  • Replace all usages of ZSTD_getDecompressedSize with ZSTD_getFrameContentSize in the platform implementations (iOS, macOS, Linux, Windows, Android, CLI) and in generated bindings where the API is called from Dart.
  • Handle the return values correctly: ZSTD_getFrameContentSize can return ZSTD_CONTENTSIZE_UNKNOWN and ZSTD_CONTENTSIZE_ERROR in addition to the size; the existing fallback (e.g. compressedSize * 20 when size is not usable) should still apply.
  • Do not add or vendor another copy of the zstd library; keep using the existing in-repo zstd sources and build setup. The current codebase already provides ZSTD_getFrameContentSize; only the call sites need to be updated.

Scope

  • Update Dart/FFI call sites that use ZSTD_getDecompressedSize to use ZSTD_getFrameContentSize and treat unknown/error values appropriately.
  • Optionally expose or use the ZSTD_CONTENTSIZE_* constants in bindings if needed for clearer logic.
  • No change to the way zstd is integrated (no new copy of zstd in Classes or elsewhere).

References

  • PR #102 (same goal; this issue tracks a minimal fix without vendoring another zstd copy).
  • zstd API: ZSTD_getFrameContentSize() replaces ZSTD_getDecompressedSize() (see zstd.h in-repo).

Reproducing the issue

Run the macOS sample app.

Flutter Version

3.41.4

Relevant Log Output

Flutter dependencies

Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

Metadata

Metadata

Assignees

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions