babalae/better-genshin-impact · error · InvalidOperationException

合成提交与确认流程失败。

Error message

合成提交与确认流程失败。

What it means

Thrown by SubmitCraftAndClaimResult when any of the three sequential UI clicks (合成 button, 确认 confirm, result 确认) times out. The inner TimeoutException comes from Page.GetByText(...).Click(5000) / WaitFor(5000) — a 5-second wait for the localized text within a bounded rect.

Source

Thrown at BetterGenshinImpact/GameTask/Common/Job/CraftMaterialTask.cs:560

    private async Task<List<RewardItem>> SubmitCraftAndClaimResult(int actualQuantity)
    {
        try
        {
            var rewards = CreateDefaultCraftRewards(actualQuantity);

            // 分别是右下角合成按钮、弹窗确认合成按钮、弹窗产物确认按钮。
            await Page.GetByText("合成", Rect1080(1588, 967, 332, 113)).Click(5000);
            await Page.GetByText("确认", Rect1080(980, 725, 370, 70)).Click(5000);

            var resultConfirmButtons = await Page.GetByText("确认", Rect1080(790, 875, 340, 65)).WaitFor(5000);
            rewards = RecognizeCraftRewards(actualQuantity);

            resultConfirmButtons.First().Click();
            return rewards;
        }
        catch (TimeoutException e)
        {
            throw new InvalidOperationException("合成提交与确认流程失败。", e);
        }
    }

    /// <summary>
    /// 识别产物弹窗中的实际合成产物,失败时回退为默认产物。
    /// </summary>
    /// <param name="actualQuantity">实际合成个数。</param>
    /// <returns>识别到的产物汇总。</returns>
    private List<RewardItem> RecognizeCraftRewards(int actualQuantity)
    {
        try
        {
            var rewardSummary = RewardResultRecognizer.Instance.RecognizeMultiPage(1);
            var rewards = rewardSummary
                .Where(pair => pair.Value > 0)
                .Select((pair, index) => new RewardItem(pair.Key, -1, pair.Value, index))
                .ToList();

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Confirm the game language matches the localized strings used by GetByText.
  2. Increase the 5000ms timeout or retry the whole submit sequence once.
  3. Before clicking 合成, assert the craft panel is in the expected state and dismiss unexpected popups.
  4. Log which of the three steps threw (wrap each Click separately) to localize the failure.

Example fix

// before
try
{
    await Page.GetByText("合成", Rect1080(1588, 967, 332, 113)).Click(5000);
    await Page.GetByText("确认", Rect1080(980, 725, 370, 70)).Click(5000);
    var resultConfirmButtons = await Page.GetByText("确认", Rect1080(790, 875, 340, 65)).WaitFor(5000);
    ...
}
catch (TimeoutException e)
{
    throw new InvalidOperationException("合成提交与确认流程失败。", e);
}

// after: identify the failing step and retry once
catch (TimeoutException e)
{
    Logger.LogError("合成确认流程超时:{Step}", e.Message);
    throw new InvalidOperationException($"合成提交与确认流程失败({e.Message})。", e);
}
Defensive patterns

Strategy: retry

Validate before calling

null

Type guard

null

Try / catch

try { return await SubmitCraftAndClaimResult(qty); }
catch (InvalidOperationException e) when (e.InnerException is TimeoutException)
{ /* dismiss unexpected popups, then retry the submit sequence once */ }

Prevention

When it happens

Trigger: Page.GetByText("合成", Rect1080(1588,967,332,113)).Click(5000) or one of the two 确认 waits throws TimeoutException because the text element was not found inside its rect within 5000ms. Triggered when the craft panel never opened, a confirm popup did not appear, or the text is in a different language/position.

Common situations: Game language does not match the expected localized strings (合成/确认); the prior SetCraftQuantity left the UI in an unexpected state so the 合成 button is absent; a popup (e.g. resin-full, material-short) blocked the confirm; capture lag exceeded 5s.

Related errors


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