Skip to content

Fix Application Freeze by Dispatching DisplayLink Updates to Main Thread#3

Open
rojinc wants to merge 1 commit intojpomykala:mainfrom
rojinc:main
Open

Fix Application Freeze by Dispatching DisplayLink Updates to Main Thread#3
rojinc wants to merge 1 commit intojpomykala:mainfrom
rojinc:main

Conversation

@rojinc
Copy link

@rojinc rojinc commented Feb 5, 2026

This PR addresses a critical bug where the application would freeze, forcing users to force-quit via Activity Monitor.

The root cause was identified in PrompterViewModel.swift. The CVDisplayLink callback runs on a background thread, but it was directly sending values to a Combine subject that triggers UI updates. Updating the UI from a background thread is undefined behavior in macOS/iOS development and led to the main thread deadlock.

This fix wraps the subject emission in DispatchQueue.main.async to ensure all UI-related updates occur safely on the main thread.

Changes
PrompterViewModel.swift: Wrapped ref.subject.send(ts) inside DispatchQueue.main.async within the CVDisplayLink output callback.

Ensure timestamp is sent on the main thread.
Copilot AI review requested due to automatic review settings February 5, 2026 01:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical application freeze issue caused by thread-safety violations in the display refresh callback. The CVDisplayLink callback executes on a background thread but was directly sending values to a Combine subject that triggers UI updates, leading to main thread deadlocks.

Changes:

  • Wrapped the subject emission in DispatchQueue.main.async within the CVDisplayLink callback to ensure thread-safe UI updates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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