{"record":{"id":"b409eca04c66b26d","repo":"babalae/better-genshin-impact","slug":"error-b409ec","errorCode":null,"errorMessage":"尝试多次后,截图失败!","messagePattern":"尝试多次后,截图失败!","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"BetterGenshinImpact/GameTask/Common/TaskControl.cs","lineNumber":294,"sourceCode":"        if (image == null)\n        {\n            captureFrame?.Dispose();\n            Logger.LogWarning(\"截图失败!\");\n            // 重试3次\n            for (var i = 0; i < 3; i++)\n            {\n                captureFrame = gameCapture?.Capture();\n                image = captureFrame?.Frame;\n                if (image != null)\n                {\n                    return image;\n                }\n\n                captureFrame?.Dispose();\n                Sleep(30);\n            }\n\n            throw new Exception(\"尝试多次后,截图失败!\");\n        }\n        else\n        {\n            return image;\n        }\n    }\n\n    public static Mat? CaptureGameImageNoRetry(IGameCapture? gameCapture)\n    {\n        return gameCapture?.Capture()?.Frame;\n    }\n\n    /// <summary>\n    /// 自动判断当前运行上下文中截图方式，并选择合适的截图方式返回\n    /// </summary>\n    /// <returns></returns>\n    public static ImageRegion CaptureToRectArea(bool forceNew = false)\n    {","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/TaskControl.cs#L276-L312","documentation":"Thrown by TaskControl.CaptureGameImage when the game-capture backend returns a null frame on the initial attempt AND on all 3 retries (30ms apart). The method first calls gameCapture?.Capture(); if Frame is null it logs '截图失败!' and retries up to 3 times; if every attempt yields a null image it throws a generic Exception. This indicates the capture source (e.g. graphics capture, window grab) is not producing frames at all.","triggerScenarios":"gameCapture is non-null but Capture() consistently returns a frame whose .Frame is null, or Capture() returns null. This happens when the capture backend lost its target (game window closed, capture session ended), the GPU/capture API is in a bad state, the game is minimized/fullscreen-exclusive and not capturable, or the capture method is incompatible with the current display mode.","commonSituations":"Game window was closed, minimized, or lost focus; capture mode (e.g. GraphicsCaptureItem) dropped the session; running in exclusive fullscreen where BitBlt/Direct3D grab fails; capture backend not initialized; another tool locked the capture; driver/overlay conflict.","solutions":["Ensure the game window is open, visible (not minimized), and running in a capturable mode (windowed or borderless).","Restart the capture backend / reattach to the game window before retrying.","Switch the configured capture method to one compatible with the current display mode.","Check for conflicting overlays (GeForce Experience, Discord, etc.) that can break capture.","Verify gameCapture is non-null and initialized before calling CaptureGameImage."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (gameCapture == null) throw new InvalidOperationException(\"截图后端未初始化\");\nvar probe = gameCapture.Capture();\nif (probe?.Frame == null) { probe?.Dispose(); throw new InvalidOperationException(\"截图后端无帧，请检查游戏窗口/捕获方式\"); }\nprobe?.Dispose();","typeGuard":"static bool IsCaptureHealthy(IGameCapture? c) => c?.Capture()?.Frame != null;","tryCatchPattern":"try { var img = TaskControl.CaptureGameImage(gameCapture); }\ncatch (Exception ex) when (ex.Message.Contains(\"截图失败\"))\n{ Logger.LogError(ex, \"截图持续失败，请确认游戏窗口可见且捕获方式兼容\"); throw; }","preventionTips":["Keep the game window visible and in windowed/borderless mode.","Re-initialize the capture backend if the window changes.","Avoid exclusive fullscreen with incompatible capture methods.","Disable conflicting overlays that can break graphics capture."],"tags":["capture","game-automation","retry-exhausted","graphics"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}