{"record":{"id":"e43d3dd9728cc5af","repo":"babalae/better-genshin-impact","slug":"error-e43d3d","errorCode":null,"errorMessage":"相对鼠标帧头不完整。","messagePattern":"相对鼠标帧头不完整。","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/Service/Instance/InstanceIpcProtocol.cs","lineNumber":203,"sourceCode":"            BinaryPrimitives.WriteInt32LittleEndian(span[(offset + sizeof(int) * 2)..], offsetMicroseconds);\n            offset += RelativeMouseSampleLength;\n        }\n\n        return payload;\n    }\n\n    internal static (ulong FirstSequence, RelativeMouseSample[] Samples) ReadRelativeMouseBatch(\n        InstanceIpcFrame frame)\n    {\n        if (frame.PayloadType != InstanceIpcPayloadType.RelativeMouseBatch)\n        {\n            throw new InvalidDataException($\"预期相对鼠标帧，实际为 {frame.PayloadType}。\");\n        }\n\n        var span = frame.Payload.AsSpan();\n        if (span.Length < RelativeMouseBatchHeaderLength)\n        {\n            throw new InvalidDataException(\"相对鼠标帧头不完整。\");\n        }\n\n        var count = BinaryPrimitives.ReadUInt16LittleEndian(span);\n        if (count is 0 or > 64\n            || span.Length != RelativeMouseBatchHeaderLength + RelativeMouseSampleLength * count)\n        {\n            throw new InvalidDataException(\"相对鼠标帧长度无效。\");\n        }\n\n        var firstSequence = BinaryPrimitives.ReadUInt64LittleEndian(span[sizeof(ushort)..]);\n        var baseTicks = BinaryPrimitives.ReadInt64LittleEndian(span[(sizeof(ushort) + sizeof(ulong))..]);\n        var samples = new RelativeMouseSample[count];\n        var offset = RelativeMouseBatchHeaderLength;\n        for (var index = 0; index < count; index++)\n        {\n            var deltaX = BinaryPrimitives.ReadInt32LittleEndian(span[offset..]);\n            var deltaY = BinaryPrimitives.ReadInt32LittleEndian(span[(offset + sizeof(int))..]);\n            var offsetMicroseconds =","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/Service/Instance/InstanceIpcProtocol.cs#L185-L221","documentation":"Thrown by ReadRelativeMouseBatch when the payload is shorter than RelativeMouseBatchHeaderLength (14 bytes: ushort count + ulong firstSequence + long baseTicks). The header cannot be read, so the batch is unparseable.","triggerScenarios":"A truncated payload reached the reader: a partial pipe write, a premature connection close mid-frame, or a peer that sent an undersized buffer. Note the framing layer (ReadFrameAsync) reads exactly payloadLength bytes, so this implies the peer declared a length too small for a valid header.","commonSituations":"Peer bug computing payload length; connection drop between header and body; memory/encoding error on the writer side; version skew where the peer uses a smaller header layout.","solutions":["Restart both instances to re-establish the pipe.","Ensure both instances run the same build (header layout must match).","If reproducing, inspect the declared payload length vs the 14-byte header minimum — a peer-side length bug is likely."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (frame.Payload.Length < RelativeMouseBatchHeaderLength)\n{\n    throw new InvalidDataException(\"相对鼠标帧头不完整。\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var (firstSeq, samples) = InstanceIpcProtocol.ReadRelativeMouseBatch(frame.Value);\n}\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"帧头不完整\"))\n{\n    logger.LogError(ex, \"Truncated mouse-batch header; restart instances\");\n}","preventionTips":["Run the same build on both ends so the header layout matches.","Restart instances to recover from truncation caused by a dropped connection.","If reproducing, compare the declared payload length to the 14-byte header minimum to locate the writer bug."],"tags":["ipc","protocol","mouse","data-corruption","named-pipe"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}