babalae/better-genshin-impact · error · TimeoutException

识别元素在 {actualTimeout}ms 后超时未消失!

Error message

识别元素在 {actualTimeout}ms 后超时未消失!

What it means

Thrown by LoadSourceAsync in MarkdownView when FilePath is set (not Markdown), the resolved file path does not exist on disk. This is a MarkdownRenderException, the view's domain exception type, indicating the Markdown source file is missing. It fires after FilePath and BasePath are resolved via ResolveFilePath.

Source

Thrown at BetterGenshinImpact/Core/BgiVision/BvLocator.cs:215

        var actualTimeout = timeout ?? _timeout ?? DefaultTimeout;
        var actualRetryInterval = _retryInterval ?? DefaultRetryInterval;
        var retryCount = Math.Max(1, actualTimeout / actualRetryInterval);

        var retryRes = await NewRetry.WaitForAction(async () =>
        {
            var results = FindAll();
            var b = results.Count == 0;
            if (!b && RetryAction != null)
            {
                await RetryAction(results);
            }

            return b;
        }, _cancellationToken, retryCount, actualRetryInterval);

        if (!retryRes)
        {
            throw new TimeoutException($"识别元素在 {actualTimeout}ms 后超时未消失!");
        }
    }

    public async Task TryWaitForDisappear(int? timeout = null)
    {
        try
        {
            await WaitForDisappear(timeout);
        }
        catch
        {
            // ignored
        }
    }

    /// <summary>
    /// 方便优雅的设置感兴趣区域 (ROI)
    /// 该方法会覆盖 RecognitionObject.RegionOfInterest 的值。

View on GitHub (pinned to a7cb36712d)

Solutions

  1. Verify the resolved filePath is correct (log it before the File.Exists check).
  2. Ensure FilePath is absolute, or that BasePath correctly points to the containing directory.
  3. Restore the missing file or update FilePath to the correct location.
  4. Handle the exception in the RenderFailedCommand to show a user-friendly message.

Example fix

// before
var filePath = ResolveFilePath(FilePath!, BasePath);
if (!File.Exists(filePath))
    throw new MarkdownRenderException($"Markdown 文件不存在:{filePath}");

// after — check and raise diagnostic event instead
var filePath = ResolveFilePath(FilePath!, BasePath);
if (!File.Exists(filePath))
{
    ReportResourceDiagnostic(new MarkdownDiagnostic(
        MarkdownDiagnosticSeverity.Error,
        $"Markdown 文件不存在:{filePath}",
        Source: FilePath));
    return null;
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate FilePath exists before rendering
var resolved = ResolveFilePath(FilePath, BasePath);
if (!File.Exists(resolved))
    ReportResourceDiagnostic(new MarkdownDiagnostic(Error, $"文件不存在:{resolved}"));

Type guard

bool IsMarkdownFileAvailable() =>
    !string.IsNullOrWhiteSpace(FilePath) && File.Exists(ResolveFilePath(FilePath, BasePath));

Try / catch

try { source = await LoadSourceAsync(ct); }
catch (MarkdownRenderException ex) { ReportResourceDiagnostic(...); source = null; }

Prevention

When it happens

Trigger: LoadSourceAsync resolves filePath = ResolveFilePath(FilePath, BasePath); File.Exists returns false. Triggered when the FilePath property points to a moved/deleted/renamed .md file, or BasePath is wrong so the combined path is invalid.

Common situations: The Markdown file was moved or deleted after the FilePath was set, a relative FilePath with a missing/wrong BasePath resolves to a non-existent location, or the path has encoding/escaping issues on the filesystem.

Understand the failure class

Related errors


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