Skip to content

fix: prevent hang on coordinator dealloc and concurrent WindowOpener waits#601

Open
datlechin wants to merge 1 commit intomainfrom
fix/perf-audit-tier1
Open

fix: prevent hang on coordinator dealloc and concurrent WindowOpener waits#601
datlechin wants to merge 1 commit intomainfrom
fix/perf-audit-tier1

Conversation

@datlechin
Copy link
Copy Markdown
Collaborator

Summary

Two fixes from the performance audit (Tier 1 critical items):

  • saveCompletionContinuation hangMainContentCoordinator.deinit now resumes the pending save continuation with false before cleanup. Previously, if the coordinator was deallocated mid-save (force close, SwiftUI view discard), the awaiting Task in MainContentCommandActions.closeAfterSave() would hang forever.

  • WindowOpener concurrent waitersreadyContinuation (single CheckedContinuation?) replaced with readyContinuations: [CheckedContinuation]. Multiple subsystems can now await waitUntilReady() concurrently at cold launch without the second caller overwriting and orphaning the first caller's continuation.

The third audit item (usleep in AutoTOTPProvider) was re-assessed as correct — it runs on a dedicated detached thread, not the cooperative pool.

Test plan

  • Edit cells → Cmd+W → save prompt works, window closes after save
  • Force-close window mid-save → no hang, app stays responsive
  • Cold launch with queued deep link URLs → all processed correctly
  • Multiple simultaneous connection attempts at startup → all connect

…waits

- Resume saveCompletionContinuation in MainContentCoordinator.deinit to
  prevent permanent hang if coordinator deallocates during save
- Support multiple concurrent waitUntilReady() callers in WindowOpener
  by using an array of continuations instead of a single optional
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