Skip to content

Fix autotracker reload lockup, stale state, and NWA address map detection (#93)#95

Merged
emosaru merged 1 commit into
mainfrom
claude/practical-leakey-7b5c36
May 18, 2026
Merged

Fix autotracker reload lockup, stale state, and NWA address map detection (#93)#95
emosaru merged 1 commit into
mainfrom
claude/practical-leakey-7b5c36

Conversation

@emosaru
Copy link
Copy Markdown
Contributor

@emosaru emosaru commented May 17, 2026

Summary

Fixes #93 (UI lockup when reloading pack with autotracker connected) plus two related issues uncovered while investigating it.

  • AutoTrackerExtension.OnAnyPackageLoadStarting — fully stop autotracking on pack reload (drain in-flight poll, disconnect active provider, fire AutoTrackerStopped, raise Active / StatusBarControl notifications). Previously the connection was preserved across reload, leaving the extension stuck in an "active/running" state that didn't actually refresh until the user manually stopped and restarted.
  • LuaMemorySegment.OnSegmentDataUpdated — re-read mCallback inside the dispatched lambda and check ScriptManager.IsLuaLoaded before calling SafeCall. A Dispatch.BeginInvoke posted from an in-flight poll just before reload would otherwise land after ScriptManager.Reset closed the Lua state and invoke a LuaFunction against a closed state — which hangs the UI thread inside NLua. This is the root-cause hang from Emotracker locks up if reloading while autotracker is connected/started #93; the null-check is defense-in-depth in case any dispatched callback slips past the new full-stop.
  • NwaDevice.ReadRawDomainAsync — replace stray space with the protocol's ; separator in the CORE_READ command used by the SNES address-map initializer. The malformed command was rejected by snes9x-nwa as a protocol error, causing ROM-header reads to throw and SNES layout detection to silently fall back to LoROM regardless of cartridge mapping.

The reload-handler change is scoped to the state being reloaded — multi-tab/multi-window setups continue polling on their other tabs undisturbed (the existing ReferenceEquals(e.Target, mState) guard).

Test plan

  • Reload pack while autotracker is connected → no UI lockup; status bar shows stopped; clicking Start reconnects and resumes polling.
  • Reload pack on tab B while tabs A and C also have autotracker running → only B stops; A and C keep polling.
  • Connect via NWA to snes9x-nwa with a HiROM cartridge → log shows Detected ROM layout: HiROM instead of LoROM; pack reads land on the correct ROM offsets.
  • Connect via NWA with an ExHiROM cartridge → detection picks ExHiROM.

🤖 Generated with Claude Code

…tion (#93)

- AutoTrackerExtension.OnAnyPackageLoadStarting: fully stop autotracking
  on pack reload instead of preserving the connection. Previously the
  extension was left in an "active/running" state that didn't actually
  refresh after reload — user had to manually stop+start. Now the reload
  drains the in-flight poll, disconnects the active provider, fires
  AutoTrackerStopped, and emits property-change for Active /
  StatusBarControl so bindings reflect the stopped state immediately.
- LuaMemorySegment.OnSegmentDataUpdated: re-read mCallback inside the
  dispatched lambda and check ScriptManager.IsLuaLoaded before invoking
  SafeCall. A Dispatch.BeginInvoke posted from an in-flight poll just
  before reload would otherwise land after ScriptManager.Reset closed
  the Lua state, hanging the UI thread inside NLua — issue #93.
- NwaDevice.ReadRawDomainAsync: replace stray space with the protocol's
  ';' separator in the CORE_READ command used by the SNES address-map
  initializer. The malformed command was rejected by snes9x-nwa as a
  protocol error, causing ROM-header reads to throw and SNES layout
  detection to silently fall back to LoROM regardless of the actual
  cartridge mapping.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@emosaru emosaru requested a review from a team May 17, 2026 22:44
@emosaru emosaru merged commit bb07e4a into main May 18, 2026
3 checks passed
@emosaru emosaru deleted the claude/practical-leakey-7b5c36 branch May 18, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emotracker locks up if reloading while autotracker is connected/started

1 participant