babalae/better-genshin-impact · error · InvalidOperationException

天赋详情 OCR 在 {MaxOcrAttempts} 次内未达到连续 {RequiredStableOcrCount}

Error message

天赋详情 OCR 在 {MaxOcrAttempts} 次内未达到连续 {RequiredStableOcrCount} 次一致,最大连续次数={stableValues.MaxConsecutiveCount},末次结果={lastResult}

What it means

`ReadTalentDetailWithRetry` requires 3 consecutive identical (type, level, hasBonus) triples within 10 attempts. Failure means the talent detail panel OCR never stabilized, so it throws rather than record an inconsistent talent level.

Source

Thrown at BetterGenshinImpact/GameTask/CharacterDevelopment/CharacterDevelopmentTask.cs:1097

                {
                    return value;
                }
            }
            else
            {
                stableValues.Reset();
                lastResult = "<解析失败>";
                _logger.LogDebug("角色养成识别:天赋详情 OCR 第 {Attempt}/{MaxAttempts} 次解析失败",
                    attempt, MaxOcrAttempts);
            }

            if (attempt < MaxOcrAttempts)
            {
                await Delay(OcrRetryDelayMilliseconds, _ct);
            }
        }

        throw new InvalidOperationException(
            $"天赋详情 OCR 在 {MaxOcrAttempts} 次内未达到连续 {RequiredStableOcrCount} 次一致," +
            $"最大连续次数={stableValues.MaxConsecutiveCount},末次结果={lastResult}");
    }

    internal static string NormalizeTalentType(string text)
    {
        if (text.Contains(AttackTalentType, StringComparison.Ordinal))
        {
            return AttackTalentType;
        }

        if (text.Contains(SkillTalentType, StringComparison.Ordinal))
        {
            return SkillTalentType;
        }

        if (text.Contains(BurstTalentType, StringComparison.Ordinal))
        {

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Wait for the talent detail panel to fully render before the first read (increase `TransitionTimeout`/delay).
  2. Re-align the talent ROIs (`Rect1080(242,13,98,36)` title, `(256,168,66,25)` level, `(35,285,146,30)` bonus) to the current layout.
  3. Increase `MaxOcrAttempts` if the jitter is transient.
  4. Preprocess the talent-title ROI to make 普通攻击/元素战技/元素爆发 reliably distinguishable.

Example fix

// before
var detail = await ReadTalentDetailWithRetry(); // throws on jitter

// after: ensure panel rendered + tuned ROIs
await Delay(400, _ct); // let animation settle
var detail = await ReadTalentDetailWithRetry();
Defensive patterns

Strategy: retry

Validate before calling

// Let the talent detail panel fully render before reading;
// confirm talent ROIs are aligned to the current layout.

Try / catch

try { await ReadTalentDetailWithRetry(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("天赋详情 OCR"))
{ /* inspect lastResult; add settle delay or retune talent ROIs */ }

Prevention

When it happens

Trigger: The talent-title, level, or bonus ROI OCRs jitter between frames; the talent detail panel is mid-animation when sampled; `NormalizeTalentType` returns empty intermittently.

Common situations: Slow panel open animation; resolution mismatch on the talent ROIs; UI layout change moving the talent title/level/bonus regions.

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/c2bbac975e79457d. Report an issue: GitHub.