Files
eagle0/editor_win.log.zip
5593effe69 Rate-limit MainQueue to prevent blocking when resuming from background (#4659)
* Rate-limit MainQueue to prevent blocking when resuming from background

When Unity is backgrounded during a Shardok game, the gRPC stream
continues receiving updates which queue up in MainQueue. Previously,
Update() would process all queued actions in a single frame, causing
the UI to freeze/spin when resuming.

This change limits processing to 10 actions per frame, spreading the
work across multiple frames and keeping the UI responsive. Also adds
logging when the queue has built up, to help diagnose similar issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Fix duplicate updates when reconnecting while Unity is backgrounded

Root cause: When Unity is backgrounded, MainQueue.Update() doesn't run,
so ReceiveGameUpdate() never processes updates and _lastUnfilteredResultCount
never advances. When the connection times out and reconnects, it sends the
stale count, causing the server to re-send all the same updates. This
repeats with each reconnect, accumulating duplicates.

Fix: Call UpdateResultCounts() immediately on the gRPC thread when updates
arrive, BEFORE enqueueing to MainQueue. This ensures reconnects always use
accurate counts regardless of MainQueue state.

Also adds duplicate detection in Notification.Append() as a defense-in-depth
measure to prevent the same text from being appended multiple times.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Implement UpdateResultCounts in CustomBattleHandler

CustomBattleHandler only handles Shardok updates, so the implementation
is a no-op.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 19:04:09 -08:00

15 KiB