{"record":{"id":"bb17a44ed21d014e","repo":"LorisYounger/VPet","slug":"invalid-fctl-chunk","errorCode":null,"errorMessage":"Invalid fcTL chunk.","messagePattern":"Invalid fcTL chunk\\.","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"VPet-Simulator.Core/Graph/APNGAnimation.cs","lineNumber":273,"sourceCode":"            while (stream.Position < stream.Length)\n            {\n                uint length = ReadUInt32BigEndian(reader);\n                string type = Encoding.ASCII.GetString(reader.ReadBytes(4));\n                byte[] data = reader.ReadBytes((int)length);\n                ReadUInt32BigEndian(reader);\n\n                switch (type)\n                {\n                    case \"IHDR\":\n                        result.IhdrTemplate = data;\n                        result.CanvasWidth = (int)ReadUInt32BigEndian(data, 0);\n                        result.CanvasHeight = (int)ReadUInt32BigEndian(data, 4);\n                        break;\n                    case \"acTL\":\n                        break;\n                    case \"fcTL\":\n                        if (data.Length < 26)\n                            throw new InvalidDataException(\"Invalid fcTL chunk.\");\n                        currentFrame = new ApngFrameData\n                        {\n                            Width = (int)ReadUInt32BigEndian(data, 4),\n                            Height = (int)ReadUInt32BigEndian(data, 8),\n                            XOffset = (int)ReadUInt32BigEndian(data, 12),\n                            YOffset = (int)ReadUInt32BigEndian(data, 16),\n                            DelayNum = ReadUInt16BigEndian(data, 20),\n                            DelayDen = ReadUInt16BigEndian(data, 22),\n                            DisposeOp = data[24],\n                            BlendOp = data[25],\n                        };\n                        result.Frames.Add(currentFrame);\n                        break;\n                    case \"IDAT\":\n                        imageDataStarted = true;\n                        if (currentFrame == null)\n                        {\n                            currentFrame = new ApngFrameData","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/LorisYounger/VPet/blob/ffb9cc2a856244a0f91aa5ecf10d097bcdd4954f/VPet-Simulator.Core/Graph/APNGAnimation.cs#L255-L291","documentation":"When ParseApng encounters an fcTL (frame control) chunk whose data is shorter than the required 26 bytes, it throws InvalidDataException. fcTL chunks carry mandatory frame geometry/timing fields, so a short chunk means the APNG is structurally malformed.","triggerScenarios":"Loading an APNG whose fcTL chunk length field is wrong or truncated so fewer than 26 data bytes are available.","commonSituations":"Corrupt downloads; hand-edited or hand-built APNGs with wrong chunk lengths; files mangled by tools that re-chunk PNG data incorrectly.","solutions":["Rebuild the APNG with apngasm/ffmpeg to regenerate valid fcTL chunks.","Re-download the asset.","Validate the PNG chunk stream (length+CRC per chunk) before loading.","Drop the file if it is not needed as an animation."],"exampleFix":"// before\nnew APNGAnimation(\"hand_edited.png\"); // short fcTL\n// after\n// apngasm -o rebuilt.png frames/*.png\nnew APNGAnimation(\"rebuilt.png\");","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var anim = new APNGAnimation(path); } catch (InvalidDataException ex) when (ex.Message.Contains(\"fcTL\")) { Log.Error($\"malformed APNG: {path}\"); LoadFallbackGraph(); }","preventionTips":["Generate APNGs only with trusted encoders (apngasm, ffmpeg)","CRC/length-validate PNG chunks in your asset pipeline","Hash-verify assets at distribution time"],"tags":["png","apng","malformed-data"],"backgroundTag":"schema-validation-failed","analyzedSha":"ffb9cc2a856244a0f91aa5ecf10d097bcdd4954f","analyzedAt":"2026-09-15T21:21:10.398Z","contentChangedAt":"2026-09-15T21:21:10.398Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}