Repository navigation
fix app hangs by decoupling menu items from high-churn app state - #3052
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change addresses app hangs caused by the
osaurusAppobserving high-churn singletons likeVADService,SpeechModelManager, andThemeManager. Previously, any@Publishedchange in these objects (e.g.,VADService.audioLevelupdates,SpeechModelManagerdownload progress) would trigger a re-evaluation of the entireCommandstree and a rebuild of the main menu on the main thread, leading to UI unresponsiveness.The fix involves refactoring the observation of these singletons to dedicated, localized views, significantly reducing main thread contention and improving overall UI responsiveness, particularly when Voice Detection is active or models are downloading.
Changes
Specifically:
vadService,speechModelManager, andthemeManageras@ObservedObjects from theosaurusAppstruct.VADToggleMenuItemas a dedicatedViewto manage the Voice Detection menu item's state and logic. It now observes only specific, less frequent changes (likevoiceConfigurationChangednotifications andSpeechModelManager.shared.selectedModelIdchanges) and callsVADService.shareddirectly.ThemeMenuItemsas a dedicatedViewto encapsulate the Theme submenu and font zoom controls. This view now locally observesThemeManager.shared.osaurusApp.swiftto guide against reintroducing high-churn@ObservedObjectsingletons at theApplevel.Test Plan
Verify that the app remains responsive, especially when:
Ensure that the Voice Detection menu item and Theme submenu function correctly.
Screenshots
If UI updated, add before/after.
Checklist
CONTRIBUTING.mdFixes APPLE-MACOS-34A
@sentry <feedback>: Autofix iterates on these changes@sentry stop iterating: Autofix stops iterating on this runThis PR was automatically generated by Sentry at no cost. You can adjust this setting at any time.