Skip to content

Empty GCD drawing queue prior to sleep#86

Merged
jdtsmith merged 1 commit intoemacs-mac-30_1_expfrom
empty-queue-on-sleep
Sep 13, 2025
Merged

Empty GCD drawing queue prior to sleep#86
jdtsmith merged 1 commit intoemacs-mac-30_1_expfrom
empty-queue-on-sleep

Conversation

@jdtsmith
Copy link
Owner

@jdtsmith jdtsmith commented Aug 24, 2025

If GCD is enabled, drawing blocks in the queue during a sleep/wake cycle
may have invalid contexts. Empty the queue prior to sleep to avoid
this.

  • src/macappkit.m ([EmacsController applicationDidFinishLaunching:]):
    Add `willSleep' observer.

Hopefully fixes #78.

If GCD is enabled, drawing blocks in the queue during a sleep/wake cycle
may have invalid contexts.  Empty the queue prior to sleep to avoid
this.

* src/macappkit.m ([EmacsController applicationDidFinishLaunching:]):
Add `willSleep' observer.
@jdtsmith
Copy link
Owner Author

For those who sleep/wake a lot and use Grand Central Dispatch (the default), please test this and report any problems. It takes ~a week for this bug to reproduce here, so I'll keep this open for a while.

@jdtsmith
Copy link
Owner Author

This seems at least to do no harm. I did encounter another similar freeze-on-wake, but it may have been without this patch. Merging, and will keep monitoring.

@jdtsmith jdtsmith merged commit 4a522f4 into emacs-mac-30_1_exp Sep 13, 2025
@jdtsmith
Copy link
Owner Author

Update: sleep seems to be related only tangentially here. It's possible this is a deadlock arising from calling sync from within a block already executing from the same queue on the main thread; see #113.

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.

GCD sync dispatch deadlock (was: freeze on awaking from sleep with different display configuration)

1 participant