Skip to content

Stable version of 3.0.8, tested for 3 weeks. - #218

Open
ParthProLegend wants to merge 9 commits into
IgorMundstein:mainfrom
ParthProLegend:main
Open

ParthProLegend wants to merge 9 commits into
IgorMundstein:mainfrom
ParthProLegend:main

Conversation

@ParthProLegend

Copy link
Copy Markdown

Summary

It is stable, but a temporary fix till you improve it later.

Related Issue

If applicable, link to the issue this PR addresses: Fixes #<issue_number>
Fixes #192 #211 #213 #190 #183

Changes

  • What did you change?
    Some Code
  • Why is this change needed?
    Unstability

Checklist

  • My code follows the project’s coding style and conventions.
  • I have tested the changes locally.
  • I have updated documentation if necessary.
  • This PR does not introduce any breaking changes.
  • I have added unit tests if applicable.

Additional Notes

Go to the repo and test the release.

shabhui and others added 9 commits September 1, 2026 16:38
The app could freeze in a state where the window stopped responding and the
process could only be ended from Task Manager.

Root cause is a lock-ordering (AB-BA) deadlock around the tray icon.
NotificationService.Update ran on a background monitor thread, took
_disposeLock, and then reached a blocking Dispatcher.Invoke by way of
GetIcon -> GetImageIcon -> Start/StopRotationAnimation. Meanwhile the UI
thread took the same _disposeLock in OnRotationTimerTick, which fires every
200ms while optimizing. Each side then waited on the other.

Because Update is called inside the view model's _lockObject, the wedged
thread held both locks, so MonitorComputer, MonitorApp and Optimize all
blocked behind it, and Dispose could never acquire _disposeLock to exit.
That is what made the process unkillable by normal means. The default
TrayIconShowMemoryUsage=false routes through the rotation animation, so the
default configuration is the affected one.

Changes:

- NotificationService: render the icon outside all locks and marshal only
  the assignment to the UI thread through a new non-blocking InvokeOnUi
  helper. Remove _disposeLock from OnRotationTimerTick. Add _iconRenderLock
  to serialize GDI reads of the shared _imageIcon, and _currentIconLock to
  guard the icon swap so concurrent callers cannot double-dispose. Marshal
  Loading and Notify, which are called from background threads and touch
  NotifyIcon members that have thread affinity. Move the timer null check
  inside the UI callback in StartRotationAnimation so two concurrent starts
  cannot both create a timer, and drop the unsynchronized _rotationTimer
  read in StopRotationAnimation that could stale-read null and leave the
  animation running.

- Dispose: DispatcherTimer has thread affinity, so Stop() from another
  thread threw and left the timer live during shutdown. Route cleanup
  through the UI thread.

- MainViewModel: the monitor loops skipped their WaitOne when IsBusy was
  set, turning both into busy-spins that pinned a core for the duration of
  an optimization. Run the delay unconditionally. Capture the
  CancellationToken once, and stop disposing the CancellationTokenSource
  while loops still hold its token, which threw ObjectDisposedException
  from the loop condition outside the try block.

- ViewModel: mark _isBusy volatile. It is written on the UI thread and
  polled by the background loops.

- MainWindow: replace Thread.Sleep(1000) on the UI thread with a
  DispatcherTimer so the grace period no longer freezes the window.

- App: add a shutdown watchdog that force-exits if a graceful shutdown
  stalls, and marshal Application.Shutdown to the UI thread.

Adds three regression tests covering concurrent Update calls, Update racing
Dispose, and Loading from a background thread.
Icon rendering used to be serialized incidentally, because Update held
_disposeLock for its whole duration. Removing that lock to break the
deadlock also removed the serialization, and the replacement
_iconRenderLock only covered GetRotatedIcon. That left a half-covered
invariant: rendering looks locked, but only one of the two paths is.

GetMemoryUsageIcon is reachable concurrently from the monitor threads and
creates its GDI objects per call, so it is safe as written today. It is
covered anyway, so that caching a Font, Brush or StringFormat in a field
later cannot silently introduce a data race.
The token-capture fix in RC1 made disposal safe: loops capture the token
once into a local at entry, and CancellationToken.IsCancellationRequested
stays usable after the source is disposed (it's a struct). Before RC1, the
loop read _cancellationTokenSource.Token fresh in the while condition,
which could throw ObjectDisposedException after disposal on a pool thread
outside the try block.

With the capture, disposing is safe and clears the CA2213 analyzer warning
that fails CI builds with /warnaserror+.
…deadlock-and-monitor-spin

Fix/tray notification deadlock and monitor spin
Co-authored-by: ParthProLegend <99063996+ParthProLegend@users.noreply.github.com>
…hub-release-job

Fix release artifact generation when SignPath is skipped
…hub-release-job-again

Fix release workflow artifact handoff when SignPath is skipped

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants