{"record":{"id":"5278b6ef08652ac4","repo":"EllanJiang/GameFramework","slug":"compressed-helper-is-invalid","errorCode":null,"errorMessage":"Compressed helper is invalid.","messagePattern":"Compressed helper is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"critical","filePath":"GameFramework/Utility/Utility.Compression.cs","lineNumber":96,"sourceCode":"                    {\n                        return null;\n                    }\n                }\n            }\n\n            /// <summary>\n            /// 压缩数据。\n            /// </summary>\n            /// <param name=\"bytes\">要压缩的数据的二进制流。</param>\n            /// <param name=\"offset\">要压缩的数据的二进制流的偏移。</param>\n            /// <param name=\"length\">要压缩的数据的二进制流的长度。</param>\n            /// <param name=\"compressedStream\">压缩后的数据的二进制流。</param>\n            /// <returns>是否压缩数据成功。</returns>\n            public static bool Compress(byte[] bytes, int offset, int length, Stream compressedStream)\n            {\n                if (s_CompressionHelper == null)\n                {\n                    throw new GameFrameworkException(\"Compressed helper is invalid.\");\n                }\n\n                if (bytes == null)\n                {\n                    throw new GameFrameworkException(\"Bytes is invalid.\");\n                }\n\n                if (offset < 0 || length < 0 || offset + length > bytes.Length)\n                {\n                    throw new GameFrameworkException(\"Offset or length is invalid.\");\n                }\n\n                if (compressedStream == null)\n                {\n                    throw new GameFrameworkException(\"Compressed stream is invalid.\");\n                }\n\n                try","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Utility/Utility.Compression.cs#L78-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"Forgetting the Utility Compression component in the Unity scene; calling compression from an editor script or very early bootstrap code before GameFramework initialization.","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"],"exampleFix":"// before\nbyte[] data = Utility.Compression.Compress(bytes, 0, bytes.Length, stream);\n// after\nCompressionHelper.SetCompressionHelper(new DefaultCompressionHelper());\nbyte[] data = Utility.Compression.Compress(bytes, 0, bytes.Length, stream);","handlingStrategy":"validation","validationCode":"// before compressing:\nif (Utility.Compression.CompressionHelperImpl == null && !compressionInitialized) throw new InvalidOperationException(\"Call SetCompressionHelper first\");","typeGuard":"null","tryCatchPattern":"try { var data = Utility.Compression.Compress(bytes, 0, bytes.Length, stream); } catch (GameFrameworkException ex) { Log.Error(\"Compression helper not set — initialize framework utilities first\"); }","preventionTips":["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"],"tags":["compression","initialization","missing-dependency"],"backgroundTag":"missing-dependency","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}