{"record":{"id":"a38cd2d30e4e7b70","repo":"babalae/better-genshin-impact","slug":"top-left-timeoutmillisec","errorCode":null,"errorMessage":"切换角色：等待单机图标、联机状态及 top_left 玩家标记超时（{timeoutMilliseconds / 1000} 秒），最后结果：{lastResult}","messagePattern":"切换角色：等待单机图标、联机状态及 top_left 玩家标记超时（(.+?) 秒），最后结果：(.+?)","errorType":"exception","errorClass":"PartySetupFailedException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs","lineNumber":1237,"sourceCode":"            }\n            finally\n            {\n                foreach (var match in matches)\n                {\n                    match.Region.Dispose();\n                }\n            }\n\n            var remainingMilliseconds = deadline - Environment.TickCount64;\n            if (remainingMilliseconds <= 0)\n            {\n                break;\n            }\n\n            await Delay((int)Math.Min(retryIntervalMilliseconds, remainingMilliseconds), ct);\n        } while (Environment.TickCount64 < deadline);\n\n        throw new PartySetupFailedException(\n            $\"切换角色：等待单机图标、联机状态及 top_left 玩家标记超时（{timeoutMilliseconds / 1000} 秒），最后结果：{lastResult}\");\n    }\n\n    private void ConfigureOperableSlots()\n    {\n        int[] physicalSlots = (_multiGamePlayerCount, _playerIndex) switch\n        {\n            (1, _) => [1, 2, 3, 4],\n            (2, 1) => [1, 2],\n            (2, 2) => [3, 4],\n            (3, 1) => [1, 2],\n            (3, 2) => [3],\n            (3, 3) => [4],\n            (4, 1) => [1],\n            (4, 2) => [2],\n            (4, 3) => [3],\n            (4, 4) => [4],\n            _ => throw new PartySetupFailedException(","sourceCodeStart":1219,"sourceCodeEnd":1255,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/Common/Job/SwitchCharacterStateMachineTask.cs#L1219-L1255","documentation":"DetectPlayerIndex polls for up to timeoutMilliseconds (5000ms) trying to confirm the play mode: either the StandAloneIcon asset (single-player), a stable MultiGameStatus, or a unique top_left player marker (1P-4P). If none resolves uniquely within the deadline it throws, because the controllable-slot layout cannot be configured.","triggerScenarios":"The do/while loop in DetectPlayerIndex exhausts the 5000ms deadline without (a) StandAloneIcon.IsExist, (b) a 1-player multi-game status, or (c) exactly one matchedPlayers entry whose index <= _multiGamePlayerCount. 'lastResult' in the message records the final partial finding.","commonSituations":"Called while not actually on the main UI (loading screen, dialog open); capture not updating; assets StandAloneIcon / NPTopLeft mismatch the current game version or scale; multiple top_left markers flicker so matchedPlayers.Length != 1 for the whole window; PartyAvatarSideIndexHelper.DetectedMultiGameStatus kept throwing (transient co-op detection instability).","solutions":["Guarantee DetectPlayerIndex runs on the main UI — return to main UI first and wait for Bv.IsInMainUi before calling.","Update RecognitionAssets StandAloneIcon and 1P-4PTopLeft templates for the current game version and capture scale.","Raise timeoutMilliseconds or retryIntervalMilliseconds if co-op status is known to stabilize slowly.","Inspect 'lastResult' in the message: '无' means no markers ever matched (asset/scale issue); a comma list means ambiguous/flickering detection (need longer settle)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if (!Bv.IsInMainUi(CaptureToRectArea()))\n{\n    await _returnMainUiTask.Start(ct);\n}","typeGuard":null,"tryCatchPattern":"try { await switchTask.Start(...); }\ncatch (PartySetupFailedException ex) when (ex.Message.Contains(\"等待单机图标\"))\n{ _logger.LogWarning(ex, \"联机状态识别超时，建议确认处于主界面后重试\"); }","preventionTips":["Ensure DetectPlayerIndex runs on the main UI only.","Keep StandAloneIcon / NPTopLeft templates current with the game version and scale.","Read 'lastResult' in the message to diagnose asset vs ambiguity causes."],"tags":["party-setup","co-op","visual-recognition","template-matching","timeout","switch-character"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}