Engine robustness: appraisal merge, AutoId re-eligibility, freeze pause, OOM dump, crash logger, transition gate
Appraisals - RequestId slot merges a pending request for the same object (PendingIdQueue), as the QueryHealth slot does. - AutoId: per-object last-sent time kept across client releases; no re-appraisal within 10 min while the data is cached, unless the server deleted the object (0xF747). Map bounded at 8192 with a prune off the create path. The sent mark is set at the real send in DrainRequestIds, not at queue time. - The selected-target priority appraisal is skipped when its data is cached and fresh. Main thread frozen - Plugin ticks pause while AC's main thread is frozen (a main-thread message box, or no beat for the hang watchdog's threshold); events keep flowing. Exposed through GetEngineStatusJson (mainThreadFrozen, mainThreadStallMs, pluginTicksPausedMs) and the heartbeat (pump=paused). Crashes - AC's OUT OF MEMORY box: one full-memory dump to <install>\Dumps before the box shows, newest 3 kept. - Native crash logger: pid, tid and date per entry; once per address; .NET Framework AVs never charged to the limit; last-chance handler; stack overflow and heap corruption codes. Build-SehTrampoline gains -NoDeploy. - ProcessExitHooks: dead fail-fast detours removed; crash exit codes pass straight through TerminateProcess/NtTerminateProcess. - CoreCLR's own crash dump is left to the loader's existing ConfigureCrashDumps (Loader.c, Logs\dumps\clr_*.dmp) and Publish-EngineCoreClr's createdump/DAC handling; this change adds no second setup. World transitions - AcMainThreadQueue holds queued game-mutating work while the player is dead, in portal space, or within 5 s after either or after a non-adjacent landblock jump. When the window ends, stale casts, uses, selects and appraisals are dropped and stops and cancels run in order. Walking across an adjacent landblock border never gates. State is re-sampled after AC's tick, before the post-tick drain. - Inventory panel actions are held during a transition too. Diagnostics - Heartbeat valargest= (largest free VA block); free and largest logged before and after each plugin load and unload. - CastSpell comments corrected to the actual main-thread paths. Tests - tools\EngineRobustnessTests and native\SehTrampoline\tests\CrashLogFilterTests.c. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b0f9d74b21
commit
55f7497065
30 changed files with 2202 additions and 419 deletions
|
|
@ -7,6 +7,10 @@
|
|||
//
|
||||
// Objects are queued from CreateObjectHooks and drained by a background timer
|
||||
// with rate-limiting to avoid flooding the server.
|
||||
//
|
||||
// Which creates get an appraisal is AutoIdEligibility's rule: an object the client
|
||||
// released and re-created is not appraised again within 10 minutes of the last one
|
||||
// while its data is still cached, unless the server deleted it (see that file).
|
||||
// ============================================================================
|
||||
|
||||
using System;
|
||||
|
|
@ -23,8 +27,16 @@ internal static class AutoIdService
|
|||
// Max RequestId calls per drain tick
|
||||
private const int MaxPerTick = 3;
|
||||
|
||||
// Skip objects already appraised this session
|
||||
private static readonly ConcurrentDictionary<uint, byte> _sent = new();
|
||||
// How long an appraisal stays good enough not to repeat: a client re-create inside
|
||||
// this window, and the selected-target priority appraisal, skip an object whose
|
||||
// appraisal is cached and this recent.
|
||||
private const long ReappraiseWindowMs = AutoIdEligibility.DefaultWindowMs;
|
||||
|
||||
// Per-object appraisal bookkeeping. Written on AC's main thread (create, client
|
||||
// release), the plugin pump (server delete) and the drain timer; every access holds
|
||||
// _gate, for a few dictionary operations only.
|
||||
private static readonly AutoIdEligibility _eligibility = new(ReappraiseWindowMs);
|
||||
private static readonly object _gate = new();
|
||||
|
||||
// Pending queue
|
||||
private static readonly ConcurrentQueue<uint> _queue = new();
|
||||
|
|
@ -32,6 +44,14 @@ internal static class AutoIdService
|
|||
private static Timer? _drainTimer;
|
||||
private static bool _started;
|
||||
|
||||
private static long _skippedRecent, _skippedPriorityFresh;
|
||||
|
||||
/// <summary>Re-creates not appraised because a recent appraisal is still cached.</summary>
|
||||
public static long SkippedRecentCount => Interlocked.Read(ref _skippedRecent);
|
||||
|
||||
/// <summary>Selected-target priority appraisals skipped because the target's data is cached and fresh.</summary>
|
||||
public static long SkippedPriorityFreshCount => Interlocked.Read(ref _skippedPriorityFresh);
|
||||
|
||||
public static void Start()
|
||||
{
|
||||
if (_started)
|
||||
|
|
@ -56,7 +76,8 @@ internal static class AutoIdService
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enqueue an object for automatic appraisal. Called from CreateObjectHooks detour.
|
||||
/// Enqueue an object for automatic appraisal. Called from CreateObjectHooks detour
|
||||
/// (AC's main thread) and the Decal bridge's create event.
|
||||
/// </summary>
|
||||
public static void Enqueue(uint objectId)
|
||||
{
|
||||
|
|
@ -68,23 +89,54 @@ internal static class AutoIdService
|
|||
if (playerId != 0 && objectId == playerId)
|
||||
return;
|
||||
|
||||
// Skip if already sent this session
|
||||
if (!_sent.TryAdd(objectId, 0))
|
||||
return;
|
||||
bool cached = AppraisalHooks.HasAppraisalData(objectId);
|
||||
AutoIdEligibility.CreateDecision decision;
|
||||
lock (_gate)
|
||||
decision = _eligibility.OnCreate(objectId, Environment.TickCount64, cached);
|
||||
|
||||
_queue.Enqueue(objectId);
|
||||
if (decision == AutoIdEligibility.CreateDecision.Appraise)
|
||||
_queue.Enqueue(objectId);
|
||||
else if (decision == AutoIdEligibility.CreateDecision.SkipRecent)
|
||||
Interlocked.Increment(ref _skippedRecent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an object from the sent set (e.g. when it's destroyed and may be recreated).
|
||||
/// The CLIENT released an object (ACCObjectMaint::DeleteObject, or the Decal bridge's
|
||||
/// delete event). A queued appraisal for it is skipped; its last appraisal time is kept,
|
||||
/// so a re-create inside the window is not appraised again.
|
||||
/// </summary>
|
||||
public static void Evict(uint objectId)
|
||||
public static void OnClientRelease(uint objectId)
|
||||
{
|
||||
_sent.TryRemove(objectId, out _);
|
||||
if (objectId == 0) return;
|
||||
lock (_gate)
|
||||
_eligibility.OnClientRelease(objectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The SERVER deleted an object (0xF747 ObjectDelete, from the server message stream on
|
||||
/// the plugin pump). Whatever is created under that id next is appraised.
|
||||
/// </summary>
|
||||
public static void OnServerDelete(uint objectId)
|
||||
{
|
||||
if (objectId == 0) return;
|
||||
lock (_gate)
|
||||
_eligibility.OnServerDelete(objectId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The 0xC8 for <paramref name="objectId"/> really went out (AcMainThreadQueue's drain, on
|
||||
/// AC's main thread, for every RequestId caller). Starts its re-appraisal window.
|
||||
/// </summary>
|
||||
public static void OnSent(uint objectId, long nowMs)
|
||||
{
|
||||
if (objectId == 0) return;
|
||||
lock (_gate)
|
||||
_eligibility.OnSent(objectId, nowMs);
|
||||
}
|
||||
|
||||
// Last target we issued a priority appraisal for (fires once per target change).
|
||||
private static uint _lastPriorityTarget;
|
||||
private static long _lastPruneMs;
|
||||
|
||||
private static void DrainTick(object? state)
|
||||
{
|
||||
|
|
@ -93,19 +145,30 @@ internal static class AutoIdService
|
|||
if (!CombatActionHooks.HasRequestId)
|
||||
return;
|
||||
|
||||
long now = Environment.TickCount64;
|
||||
int sent = 0;
|
||||
|
||||
// Combat-target priority: when the selected target CHANGES, appraise it
|
||||
// immediately — enqueued ahead of the create-order backlog so a fast kill
|
||||
// still gets its max-HP appraisal out first instead of waiting behind the
|
||||
// whole spawn. Fires once per change (guarded), so no per-tick re-appraisal.
|
||||
// Skipped when the target's appraisal is already cached and fresh: selecting
|
||||
// something identified a minute ago asked the server again for nothing.
|
||||
uint target = SelectedTargetHooks.ReadCurrentSelectedId();
|
||||
if (target != 0 && target != _lastPriorityTarget)
|
||||
{
|
||||
_lastPriorityTarget = target;
|
||||
uint playerId = ClientHelperHooks.GetPlayerId();
|
||||
if (target != playerId && AcMainThreadQueue.EnqueueRequestId(target))
|
||||
sent++;
|
||||
if (target != playerId)
|
||||
{
|
||||
bool fresh = AutoIdEligibility.IsAppraisalFresh(
|
||||
AppraisalHooks.HasAppraisalData(target), AppraisalHooks.GetLastIdTime(target),
|
||||
DateTimeOffset.UtcNow.ToUnixTimeSeconds(), ReappraiseWindowMs);
|
||||
if (fresh)
|
||||
Interlocked.Increment(ref _skippedPriorityFresh);
|
||||
else if (AcMainThreadQueue.EnqueueRequestId(target))
|
||||
sent++;
|
||||
}
|
||||
}
|
||||
|
||||
while (sent < MaxPerTick && _queue.TryDequeue(out uint objectId))
|
||||
|
|
@ -113,20 +176,37 @@ internal static class AutoIdService
|
|||
// Object may have been destroyed between enqueue and drain
|
||||
if (objectId == 0)
|
||||
continue;
|
||||
// Deleted since it was queued: Evict took it out of _sent. Skip it without
|
||||
// spending one of the 3 requests per tick. After a big landblock change (the
|
||||
// 585 deletes of 2026-10-02) the queue otherwise kept asking the server to
|
||||
// appraise gone objects at 30 a second for half a minute, and live ones waited.
|
||||
// A delete-then-recreate is queued again by Enqueue, so nothing live is lost.
|
||||
if (!_sent.ContainsKey(objectId))
|
||||
// Released since it was queued: skip it without spending one of the 3
|
||||
// requests per tick. After a big landblock change (the 585 deletes of
|
||||
// one jump) the queue otherwise kept asking the server to appraise gone
|
||||
// objects at 30 a second for half a minute, and live ones waited. A
|
||||
// release-then-recreate is decided again by Enqueue, so nothing live is lost.
|
||||
bool live;
|
||||
lock (_gate) live = _eligibility.IsLive(objectId);
|
||||
if (!live)
|
||||
continue;
|
||||
|
||||
// Marshal onto AC's main thread (EndScene drain) — the Timer thread must
|
||||
// not call the native 0xC8 send directly (off-thread heap alloc + non-atomic
|
||||
// UI-counter increment). EnqueueRequestId is the marshalled path.
|
||||
// UI-counter increment). EnqueueRequestId is the marshalled path. The
|
||||
// appraisal counts as sent only when the main thread sends it (OnSent, from
|
||||
// AcMainThreadQueue.DrainRequestIds): a queued request that is dropped there
|
||||
// leaves the object due again.
|
||||
AcMainThreadQueue.EnqueueRequestId(objectId);
|
||||
sent++;
|
||||
}
|
||||
|
||||
// Keep the bookkeeping bounded. Here, off AC's main thread: the create path
|
||||
// never prunes.
|
||||
if (now - _lastPruneMs >= 10_000)
|
||||
{
|
||||
_lastPruneMs = now;
|
||||
int removed;
|
||||
lock (_gate)
|
||||
removed = _eligibility.Count > _eligibility.MaxTracked / 2 ? _eligibility.Prune(now) : 0;
|
||||
if (removed > 0)
|
||||
RynthLog.Verbose($"Compat: AutoIdService pruned {removed} appraisal record(s).");
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue