Skip to content

pinmame: stop native emulation before editor assembly reload - #47

Merged
freezy merged 1 commit into
masterfrom
feat/mech-sounds
Oct 21, 2026
Merged

freezy merged 1 commit into
masterfrom
feat/mech-sounds

Conversation

@freezy

@freezy freezy commented Oct 21, 2026

Copy link
Copy Markdown
Member

Recompiling scripts while PinMAME was running could leave its native emulation thread holding callbacks from an unloaded Unity scripting domain. A later stop then jumped through an invalid managed callback and crashed the editor.

Stop simulation and synchronously stop/join PinMAME before assembly reload, including inactive tables and finished native threads. Release the time fence even without a scene engine. Only detach scene-engine callbacks while playing so edit-mode hot reload preserves the flags needed for the next Play session. The existing play-mode-exit and editor-quit paths use the same synchronous cleanup.

Validation on Unity 6000.5 Windows Editor: two native ROM reloads and three starts, a full T2 Play run and runtime .vpe replacement, edit-mode recompilation with scene/domain reload disabled, recompilation during live simulation, and ordinary Play to Stop. Native shutdown completed before unloading; all 11 managed event subscriptions were detached on ordinary exit. Opus 5.5 reviewed the fix and the correction to edit-mode teardown before commit.

@greptile-apps

greptile-apps Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Stops PinMAME before Unity reloads its scripting assemblies.

  • PinMAME now stops before Unity reloads editor scripts.

No actionable issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Before assembly reload] --> D[RequestStop]
  B[Exiting Play mode] --> D
  C[Editor quitting] --> D
  D --> E[Stop simulation, including inactive tables]
  E --> F{Editor is playing?}
  F -->|Yes| G[Detach scene-engine callbacks]
  F -->|No| H[Release native time fence]
  G --> H
  H --> I[Stop native emulation synchronously]
  I --> J[Clear stopping flag]
Loading

Reviews (1) · Last reviewed commit: "pinmame: stop native emulation before ed..." · Reviewed by Greptile

@freezy
freezy merged commit 3edfbbc into master Oct 21, 2026
17 checks passed
@freezy
freezy deleted the feat/mech-sounds branch October 21, 2026 18:16
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.

1 participant