Skip to content

Fix duplicate instances remaining after update - #795

Open
sfasano wants to merge 4 commits into
altic-dev:mainfrom
sfasano:fix-multiple-instances
Open

Fix duplicate instances remaining after update#795
sfasano wants to merge 4 commits into
altic-dev:mainfrom
sfasano:fix-multiple-instances

Conversation

@sfasano

@sfasano sfasano commented Aug 5, 2026

Copy link
Copy Markdown

Description

Replaced NSApp.terminate(nil) with exit(0) in SimpleUpdater.swift. This ensures the old instance forcefully quits after launching the new application instance, preventing a race condition where duplicate processes run simultaneously and fight over the global hotkey and microphone.

Type of Change

  • 🐞 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 🧹 Chore
  • 📝 Documentation update

Related Issue or Discussion

Closes #794

Testing

  • Tested on Intel Mac
  • Tested on Apple Silicon Mac
  • Tested on macOS version: 15.7
  • Ran linter locally: swiftlint --strict --config .swiftlint.yml Sources
  • Ran formatter locally: swiftformat --config .swiftformat Sources
  • Ran tests locally:

Screenshots / Video

  • No UI/visual changes; screenshots/video are not applicable.

Notes

The exit(0) call prevents the application from lingering in the background if the runloop is blocked during an update.

@github-actions github-actions Bot added needs PR template Pull request is missing required template content. needs screenshots Pull request needs screenshot or video evidence. labels Aug 5, 2026
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

The PR Policy check is blocking this PR because required template information is missing.

Please update the PR description with:

  • Description
  • Type of Change
  • Related Issue or Discussion
  • Testing
  • Screenshots / Video

Screenshots or video are required for UI, UX, settings, onboarding, overlay, menu bar, or visual behavior changes. If this PR has no visual changes, check the no-visual-change box in the template.

If this remains incomplete for 48 hours after opening, the PR may be closed.

@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown

Greptile Summary

The PR moves the updater’s fallback watchdog ahead of NSApp.terminate(nil), ensuring it remains armed if AppKit termination blocks.

  • Schedules a background forced-exit fallback after 20 seconds.
  • Preserves normal AppDelegate termination cleanup before the fallback can fire.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (4): Last reviewed commit: "Address review: Arm the fallback watchdo..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bc418acc8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Sources/Fluid/Services/SimpleUpdater.swift Outdated
Comment thread Sources/Fluid/Services/SimpleUpdater.swift Outdated
@github-actions github-actions Bot removed needs PR template Pull request is missing required template content. needs screenshots Pull request needs screenshot or video evidence. labels Aug 5, 2026
Comment thread Sources/Fluid/Services/SimpleUpdater.swift Outdated
Comment thread Sources/Fluid/Services/SimpleUpdater.swift
…ate to ensure it schedules before termination blocks the main thread
@altic-dev

Copy link
Copy Markdown
Owner

Thanks for the PR. I'm not sure if killing it forcefully will remove the memory occupied by models that FluidVoice loads. Did you happen to take a look at that?

In the current update I added a waiter so it waits to make sure the update happens clearly so - from next update it should fix this better

@sfasano

sfasano commented Aug 5, 2026

Copy link
Copy Markdown
Author

Thanks for taking a look!

RE: memory: yes, even if the process is forcefully killed, the macOS kernel will completely reclaim all unified memory and MLX buffers assigned to that PID. It won't cause a system-level memory leak.

However, with the latest commits on this PR, the exit(0) acts strictly as a 'dead man's switch' fallback. We call NSApp.terminate(nil) first, which triggers AppDelegate.applicationWillTerminate so the models gracefully unload themselves 99% of the time. The 20-second fallback timer only fires if the graceful cleanup completely deadlocks and refuses to quit.

That being said, if you've already implemented a proper waiter in the upcoming release that handles the update lifecycle more cleanly, feel free to just close this PR! I mainly wanted to get a safety net in place because the duplicate background instances were causing global hotkey collisions on my machine.

@altic-dev

Copy link
Copy Markdown
Owner

Thanks a lot @sfasano - let's try my current method to see if it fixes it - if not we'll come work on this together :)

PS : we're also workin on a new updater to solve all this. That will solve all of the current issues.

Really appreciate your support in this :)

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.

Race condition in AppDelegate causes multiple app instances during LaunchServices reopen

2 participants