Snapshot for release 2026.10.21.3 (internal 04b831a)

This commit is contained in:
Tom Bohar 2026-10-21 21:03:43 -04:00
commit c4efe5821d
46 changed files with 2657 additions and 213 deletions

View file

@ -5,13 +5,17 @@
//
// Order matters. Each phase is wrapped so a failure does not abort the rest:
//
// 0. TickPump.StopAndJoin — the plugin pump stops (and its frame in flight
// finishes) before any plugin is shut down: no Tick alongside a Shutdown.
// 1. EndSceneHook.Uninstall — chains into EngineFrameController.Shutdown which
// tears down PluginManager (RynthPluginShutdown + FreeLibrary plugins),
// OverlayTextureRenderer, DX9Backend, and destroys the ImGui context.
// 2. Drain — sleep so any in-flight EndScene call has returned through the
// trampoline before we tear down anything else.
// 3. AvaloniaOverlay.Stop — Dispatcher shutdown, join STA thread.
// 4. PluginManager.ShutdownAll — defensive (no-op if step 1 already ran).
// 4. PluginManager.ShutdownAll — defensive (no-op if step 1 already ran; it
// tries again if step 1 left the plugins alone because the pump was
// still inside a frame).
// 5. MH_DisableHook(ALL) + MH_Uninitialize — safety net for Compatibility/*
// hooks that aren't in the ImGui chain.
//
@ -140,6 +144,17 @@ internal static class EngineLifecycle
// plugin-mutating UI command while the plugins are shutting down.
Step("UiDataHub.Disarm", () => UI.Data.UiDataHub.Disarm());
// Stop the plugin pump (and wait for a frame in flight) BEFORE anything below can
// shut a plugin down: EndSceneHook.Uninstall runs PluginManager.ShutdownAll (through
// EngineFrameController.Shutdown), and a pump still running would call a plugin's Tick
// and events on its own thread while that plugin's Shutdown frees what they use on
// this one (audit 2026-10-21, 01 #1). It used to stop further down, after the plugins
// were already gone; only the WM_CLOSE path (Win32Backend) stopped it first. Every
// shutdown comes through here: the loader's hot reload, ExitProcess and
// RtlExitUserProcess, WM_CLOSE, the bar's Sd button. If a frame is still running when
// the wait ends, ShutdownAll leaves the plugins alone (PluginShutdownGate).
Step("TickPump.StopAndJoin", () => EntryPoint.StopTickPumpAndJoin());
// AC's UI-pass hook draws the world overlays mid-frame from the same render-side
// state EndSceneHook.Uninstall tears down: stop it first (its 80 ms drain covers both).
Step("AcUiPassHook.Uninstall", () => AcUiPassHook.Uninstall());
@ -166,17 +181,14 @@ internal static class EngineLifecycle
Step("Win32Backend.Shutdown (input subclass)", () => ImGuiBackend.Win32Backend.Shutdown());
Step("HotkeyService.Shutdown", () => Hotkeys.HotkeyService.Shutdown());
// Stop the dispatch-file watcher and the auto-ID drain timer before the
// tick pump and plugins go away — both otherwise keep firing in the old
// generation's (intentionally still-mapped) module across hot-reloads.
// Stop the dispatch-file watcher and the auto-ID drain timer — both
// otherwise keep firing in the old generation's (intentionally
// still-mapped) module across hot-reloads.
Step("ChatFileDispatcher.Stop", () => Compatibility.ChatFileDispatcher.Stop());
Step("LogSettings.StopWatcher", () => LogSettings.StopWatcher());
Step("AutoIdService.Stop", () => Compatibility.AutoIdService.Stop());
// Stop the headless tick pump BEFORE plugin shutdown / FreeLibrary.
// Otherwise the pump's TickAll/ProcessPendingActions can be mid-call
// into a plugin whose code pages we're about to unmap → AV.
Step("TickPump.StopAndJoin", () => EntryPoint.StopTickPumpAndJoin());
// (The plugin pump stopped at the top, before the plugins were shut down.)
// spike/decal-bridge: after the pump (its only reader) has stopped.
Step("DecalBridgeHost.Shutdown", () => Compatibility.DecalBridgeHost.Shutdown());