Skip to content

P0: make ARStack Studio shutdown deterministic on Windows - #99

Draft
masarray wants to merge 10 commits into
mainfrom
fix/studio-graceful-shutdown-p0
Draft

masarray wants to merge 10 commits into
mainfrom
fix/studio-graceful-shutdown-p0

Conversation

@masarray

Copy link
Copy Markdown
Owner

Critical defect

Closing the Studio window can leave ARStackStudio.exe resident on Windows. The stale process retains single-instance/session ownership so the next launch appears to do nothing.

This violates the repository lifecycle contract in AGENTS.md: stop new work, cancel/retire timers and callbacks, join workers, release handles, and never leave teardown unbounded.

Root cause

Shutdown authority was fragmented:

  • QML close only requested SMV STOP;
  • StudioDeviceController owned a separate aboutToQuit hook;
  • FirmwareManager owned another quit hook;
  • SmartSessionController had no explicit teardown boundary;
  • DeviceController and FirmwareManager used Qt::BlockingQueuedConnection plus unbounded QThread::wait() during destruction.

That makes Windows process exit depend on QObject/QML destruction order after the GUI event loop is already ending.

Fix

  • Add explicit idempotent SmartSessionController::shutdown() to stop discovery/reconnect/profile-sync/handoff/recovery callback owners first.
  • Add explicit bounded DeviceController::shutdown() that requests worker-side STOP/serial close, waits for acknowledgement with a deadline, then performs bounded QThread retirement.
  • Apply the same bounded retirement contract to FirmwareManager / FirmwareWorker.
  • Remove the competing StudioDeviceController app-quit hook.
  • Make main.cpp the single shutdown coordinator while worker event loops are still alive: supervisor -> serial worker -> firmware worker.
  • Treat emergency thread termination only as last-resort process-exit containment; reaching it reports lifecycle failure and must fail CI.

Permanent regression gate

Adds ARStack Studio Windows Lifecycle CI. It builds the actual Studio GUI executable on Windows and performs two consecutive cycles:

  1. launch with --check-app-lifecycle;
  2. close primary window;
  3. require clean worker-retirement PASS and actual PID exit within 12 s;
  4. immediately reopen the application;
  5. require a second clean exit.

This directly proves the reported failure mode: close -> process exit -> lock release -> immediate reopen.

Isolation

No embedded firmware, PTP engine, or apps/ied_simulator/** source is changed.

Merge gate

Keep draft until exact-head Windows lifecycle, existing Studio Qt, S8A/S8B ownership, and repository CI are green. Then validate one packaged Windows build manually against Task Manager before merge/release.

Copy link
Copy Markdown
Owner Author

P0 lifecycle checkpoint — exact-head candidate ready for physical Windows verification

Exact PR head: dbb564e396ed6e6b064b9b79ad21de110d1f342d

Automated validation is now green:

  • ARStack Studio Windows Lifecycle PASS: two consecutive launch -> primary close -> clean worker retirement -> PID exit -> immediate reopen cycles on Windows Server 2022.
  • ARStack Studio Qt, C++ CI, Security/Evidence, Embedded Profile, Control Interop, Dynamic RCB and BRCB gates PASS.
  • ARStack Studio Release run 34945762813 PASS end-to-end.
  • Native Windows S8A/S8B ownership gates PASS.
  • Packaged application contract PASS.
  • Fresh Windows package smoke PASS for both portable ZIP and NSIS-installed build with restricted PATH, including packaged lifecycle check and single-instance ownership check.

Release-candidate artifact:

  • artifact arstack-studio-windows-x64
  • artifact ID 10386788450
  • artifact digest sha256:93c114375c71ca856e27745eb5d5ed5ecd2bea9c93fe5e1d8fd9b173309a593f
  • portable SHA-256 451547321b27582db72a6101bfdb7ae49c6076c9654a8879024093f345c89da7
  • installer SHA-256 ec216397dbde1338cd7f649d14ab118e58d4b93118d41f1181e723ea3d0b68aa

PR remains draft until one real-PC verification against the originally reported symptom: start packaged Studio, close it normally, confirm ARStackStudio.exe disappears from Task Manager, immediately open again, then close again and confirm PID disappears. No firmware/PTP/IED Simulator files are part of this lifecycle fix scope.

Copy link
Copy Markdown
Owner Author

Exact-head lifecycle checkpoint

Candidate head: dbb564e396ed6e6b064b9b79ad21de110d1f342d

Validation completed on this exact head:

  • ARStack Studio Windows Lifecycle: PASS
    • cycle 1: close -> clean worker retirement -> PID exit
    • cycle 2: immediate reopen -> close -> clean worker retirement -> PID exit
  • ARStack Studio Qt: PASS
  • C++ CI: PASS
  • Security and Evidence: PASS
  • embedded/interoperability/RCB gates: PASS
  • ARStack Studio Release: PASS
    • native Windows Release build
    • S8A/S8B Windows integration gates
    • package contract
    • portable ZIP
    • NSIS installer
    • fresh-Windows portable + installer smoke under restricted PATH

Windows candidate artifact:

  • artifact ID 10386788450
  • artifact digest sha256:93c114375c71ca856e27745eb5d5ed5ecd2bea9c93fe5e1d8fd9b173309a593f
  • portable SHA-256 451547321b27582db72a6101bfdb7ae49c6076c9654a8879024093f345c89da7
  • installer SHA-256 ec216397dbde1338cd7f649d14ab118e58d4b93118d41f1181e723ea3d0b68aa

PR remains draft until one real Windows/board session confirms the reported field failure mode is gone: close Studio while a real session is active, confirm ARStackStudio.exe disappears from Task Manager, then reopen immediately. No embedded/PTP/IED Simulator source is changed by this PR.

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