EllanJiang/GameFramework · critical · GameFrameworkException
Compressed helper is invalid.
Error message
Compressed helper is invalid.
What it means
The full Compress overload requires a compression helper to have been registered via SetCompressionHelper (e.g. in a Unity entry point). This exception is thrown when s_CompressionHelper is still null, meaning the utility was never initialized before compression was requested.
Solutions
- Call CompressionHelper.SetCompressionHelper(new CompressionHelperImpl()) (or add the Utility component) before any compress call
- Check script execution order / initialization sequence so setup runs before usage
- Confirm the component that performs registration is enabled in the active scene
Example fix
// before byte[] data = Utility.Compression.Compress(bytes, 0, bytes.Length, stream); // after CompressionHelper.SetCompressionHelper(new DefaultCompressionHelper()); byte[] data = Utility.Compression.Compress(bytes, 0, bytes.Length, stream);
Defensive patterns
Strategy: validation
Validate before calling
// before compressing:
if (Utility.Compression.CompressionHelperImpl == null && !compressionInitialized) throw new InvalidOperationException("Call SetCompressionHelper first"); Type guard
null
Try / catch
try { var data = Utility.Compression.Compress(bytes, 0, bytes.Length, stream); } catch (GameFrameworkException ex) { Log.Error("Compression helper not set — initialize framework utilities first"); } Prevention
- Register the compression helper in the game entry (GameEntry/ProcedureLaunch)
- Add the Utility compression component to the bootstrap scene
- Verify script execution order for initialization scripts
- Smoke-test compression in a startup self-check
When it happens
Trigger: Calling Utility.Compression.Compress before CompressionHelper.SetCompressionHelper was called; initialization code skipped because a component's Awake/Start did not run or ordering put the compress call first.
Common situations: Forgetting the Utility Compression component in the Unity scene; calling compression from an editor script or very early bootstrap code before GameFramework initialization.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- You must set resource manager first.
- You must set data provider helper first.
- You must set data helper first.
- Resource helper is invalid.
- JSON helper is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/5278b6ef08652ac4.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Utility/Utility.Compression.cs:96
{
return null;
}
}
}
/// <summary>
/// 压缩数据。
/// </summary>
/// <param name="bytes">要压缩的数据的二进制流。</param>
/// <param name="offset">要压缩的数据的二进制流的偏移。</param>
/// <param name="length">要压缩的数据的二进制流的长度。</param>
/// <param name="compressedStream">压缩后的数据的二进制流。</param>
/// <returns>是否压缩数据成功。</returns>
public static bool Compress(byte[] bytes, int offset, int length, Stream compressedStream)
{
if (s_CompressionHelper == null)
{
throw new GameFrameworkException("Compressed helper is invalid.");
}
if (bytes == null)
{
throw new GameFrameworkException("Bytes is invalid.");
}
if (offset < 0 || length < 0 || offset + length > bytes.Length)
{
throw new GameFrameworkException("Offset or length is invalid.");
}
if (compressedStream == null)
{
throw new GameFrameworkException("Compressed stream is invalid.");
}
tryView on GitHub (pinned to d0c010b051)