fix(walker): convert unbounded recursion to iterative loop#1759
fix(walker): convert unbounded recursion to iterative loop#1759seppulcro wants to merge 3 commits intochsami:developmentfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java`:
- Around line 615-622: recalcAttempts is being incremented every loop iteration
in Rs2Walker (causing premature UNREACHABLE returns); change logic so
recalcAttempts is only incremented when you actually trigger a path
recalculation (e.g., inside the branch that calls recalculatePath() or in the
stall-detection branch), not on normal progress or "off-path-but-moving" wait
branches, and reset recalcAttempts to 0 whenever the walker makes forward
progress or a new valid path is established; keep the existing behavior that
when recalcAttempts >= MAX_RECALC_ATTEMPTS you log, setTarget(null), and return
WalkerState.UNREACHABLE.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9153c4b8-5e82-4efa-8e85-2ec93b5eda5b
📒 Files selected for processing (1)
runelite-client/src/main/java/net/runelite/client/plugins/microbot/util/walker/Rs2Walker.java
0415515 to
7e25f66
Compare
processWalk() calls itself recursively at 3 sites with no depth limit. When the walker gets stuck (e.g. near obstacles on long paths), this floods the client thread task queue causing cascading TimeoutExceptions that freeze the entire client. Replace recursive processWalk() calls with a while(true) loop capped at MAX_RECALC_ATTEMPTS=15. Returns UNREACHABLE cleanly instead of crashing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
7e25f66 to
2028d84
Compare
off-path-but-moving is normal forward progress and should not count toward the MAX_RECALC_ATTEMPTS limit. This prevents premature UNREACHABLE returns on valid long walks. Addresses CodeRabbit review feedback. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Added an additional with a couple more fixes I noticed while trying to use walker
When the player is adjacent (dist ≤ 1) to a target tile that isn't walkable (e.g. NPC spawn tile, object, wall), return ARRIVED immediately instead of burning all 15 recalc attempts. This was the root cause of the Exceeded max recalc attempts spam during quest helper walks — the pathfinder finds a route but the
walkMiniMap(WorldPoint) was delegating to walkMiniMap(wp, 5) which force-resets the minimap zoom to 5.0 on every single walk click. This is detectable bot behaviour — real players don't snap their zoom level 50 times a minute. The no-arg overload now reads the current minimap position directly without touching |
When the player is adjacent (dist≤1) to an unwalkable target tile (NPC, object, wall), return ARRIVED immediately instead of burning all 15 recalc attempts on a tile that can never be reached. When recalc attempts are exhausted but the player is within max(distance, 5) tiles of the target, treat as ARRIVED instead of UNREACHABLE. The ShortestPath pathfinder only considers exact tile matches as 'reached' — when the target tile has collision flags, the best path ends 1 tile short. The walker should accept that as success. Also stop resetting minimap zoom to 5 on every walkMiniMap() call — preserve the player's current zoom level. The forced zoom reset is detectable bot behaviour. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e0703b7 to
3e22ad9
Compare
Bug: Walking long paths via world map (e.g. to Lighthouse for Horror from the Deep) causes the client to freeze with cascading TimeoutExceptions when the
walker hits a stuck condition near obstacles.
Cause: processWalk() recurses at 3 call sites with no depth limit, flooding the client thread queue.
Fix: Iterative while(true) loop with MAX_RECALC_ATTEMPTS=15. Returns UNREACHABLE cleanly instead of crashing.