babalae/better-genshin-impact · error · InvalidOperationException
多次重试后,识别大地图位置失败
Error message
多次重试后,识别大地图位置失败
What it means
Thrown by GetBigMapRect after NewRetry.Do exhausts 5 retry attempts (each at BigMapRectRetryIntervalMs interval) and the recognized rect is still default. The retry body throws RetryException for two reasons: either the MapScaleButton isn't found (not on map interface) or MapManager.GetMap(...).GetBigMapRect returns default. After all retries, the outer check throws InvalidOperationException.
Source
Thrown at BetterGenshinImpact/GameTask/AutoTrackPath/TpTask.cs:2114
catch (Exception)
{
rect = default; // 发生异常视为识别失败
}
if (rect == default)
{
throw new RetryException("识别大地图位置失败");
}
}
else
{
throw new RetryException("当前不在地图界面");
}
}, TimeSpan.FromMilliseconds(BigMapRectRetryIntervalMs), 5);
if (rect == default)
{
throw new InvalidOperationException("多次重试后,识别大地图位置失败");
}
// 提瓦特大陆由于用的256的图,需要做特殊逻辑
if (mapName == MapTypes.Teyvat.ToString())
{
const int s = TeyvatMap.BigMap256ScaleTo2048; // 相对2048做8倍缩放
rect = new Rect(rect.X * s, rect.Y * s, rect.Width * s, rect.Height * s);
}
return MapManager.GetMap(mapName, _mapMatchingMethod).ConvertImageCoordinatesToGenshinMapCoordinates(rect)!.Value;
}
public Point2f GetBigMapCenterPoint(string mapName)
{
return GetBigMapCenterPoint(mapName, null);
}
private Point2f GetBigMapCenterPoint(string mapName, Point2f? expectedCenterPoint)View on GitHub (pinned to a7cb36712d)
Solutions
- Ensure the big map UI is fully loaded and visible before calling GetBigMapRect.
- Verify mapName matches a loaded/available map type.
- Increase BigMapRectRetryIntervalMs or retry count if the game is slow to render.
- Check that map recognition assets are current for the installed game version.
- Ensure the capture resolution matches the expected game window size.
Defensive patterns
Strategy: try-catch
Try / catch
try
{
var rect = task.GetBigMapRect(mapName);
}
catch (InvalidOperationException ex) when (ex.Message == "多次重试后,识别大地图位置失败")
{
Logger.LogError($"Big map rect recognition failed for {mapName}. Ensure the map is open.");
throw;
} Prevention
- Ensure the big map is fully rendered before calling GetBigMapRect.
- Keep map recognition assets current with the game version.
- Verify the capture resolution matches expected dimensions.
- Increase retry interval if the game renders slowly.
When it happens
Trigger: Called from GetBigMapRect(mapName). The retry callback either finds no MapScaleButton (not on map screen) or GetBigMapRect returns default rect due to feature matching failure, for 5 consecutive attempts.
Common situations: Game not navigated to the big map before calling; map UI animation still loading; map assets mismatched with current game version; low-resolution or scaled capture preventing template matching; the wrong mapName is passed.
Related errors
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/e0dcc164b33baba1.
Report an issue: GitHub.