Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emacs is freezed at switch #28

Closed
follow39 opened this issue Jun 29, 2023 · 11 comments · Fixed by #31 · May be fixed by #35
Closed

Emacs is freezed at switch #28

follow39 opened this issue Jun 29, 2023 · 11 comments · Fixed by #31 · May be fixed by #35
Assignees
Milestone

Comments

@follow39
Copy link

Hello!
I have a problem - Emacs is completely freezed while swithing process. Theme is swithed but Emacs doesn't respond at all.

Related config:

(use-package ef-themes
  :straight (:host github :repo "protesilaos/ef-themes")
  :defer)

(use-package circadian
  :straight (:host github :repo "guidoschmidt/circadian.el")
  :requires (local-config)
  :custom
  ;; (circadian-themes '(("7:30" . ef-light)
  ;;                     ("19:30" . ef-night)))
  (calendar-latitude 44.786568)
  (calendar-longitude 20.448921)
  (circadian-themes '((:sunrise . ef-light)
                      (:sunset  . ef-night)))
  :config
  (circadian-setup))

Full config

  1. GNU Emacs 29.0.90 (build 1, aarch64-apple-darwin22.4.0, NS
    appkit-2299.50 Version 13.3.1 (a) (Build 22E772610a)) of 2023-05-04
    MacOS 13.4.1 (22F82)
    Circadian: 52e336d
    Ef-themes: 27bf0ff4d9218c382fbaa512efb754f19b667678
  2. GNU Emacs 29.0.91 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20,
    cairo version 1.16.0) of 2023-06-04
    Ubuntu 20.04.6 LTS
    Circadian: 52e336d
    Ef-themes: 27bf0ff4d9218c382fbaa512efb754f19b667678
@DerGuteMoritz
Copy link

Same here. When it happens, the process is spinning with 100% CPU utlization.

@guidoschmidt
Copy link
Owner

guidoschmidt commented Oct 27, 2023

Hey thanks for reporting, unfortunatelly I'm tend to get behind maintaining circadian.el. If one of you feels keen enough to debug this, it would be highly appreciated.

luckysori added a commit to luckysori/dotemacs that referenced this issue Feb 17, 2024
Cool idea, but emacs just freezes for minutes every time we switch.
See guidoschmidt/circadian.el#28.
@meedstrom
Copy link

meedstrom commented Mar 7, 2024

Mine didn't freeze, but Emacs was super-slow for a while.

I caught the reason with a profiler (so nice to have the profiler on a hotkey!): 57% CPU on timer-event-handler calling circadian-activate-latest-theme. Repeatedly, I assume.

When Emacs was snappy again, I noted the time was 18:01. So perhaps it keeps running for the whole minute?

Test specifying the time as 18:00:00 instead of just 18:00.

@meedstrom
Copy link

meedstrom commented Mar 7, 2024

I found something interesting, it seems that Emacs' run-at-time function, passed "18:00" will run right away even if it is now 18:00:59!

That may or may not be related.

If it is, the source of the error must be that circadian is re-scheduling the same theme until the clock is definitely greater. I propose changing the little <= inside circadian-a-earlier-b-p to a <. I haven't tested if that makes a difference yet. I don't always get the bug in the first place, so it'd be good if someone else can say if it makes a difference.

@xeechou
Copy link

xeechou commented Mar 8, 2024

same here. It's cause huge issue in CPU usage on windows.

@divyaranjan1905
Copy link

Hey thanks for reporting, unfortunatelly I'm tend to get behind maintaining circadian.el. If one of you feels keen enough to debug this, it would be highly appreciated.

If you haven't been able to maintain the package, would you mind if I step up as a maintainer? I've been using this package for almost more than an year and would rather not let this die.

@guidoschmidt
Copy link
Owner

guidoschmidt commented Apr 17, 2024

@divyaranjan1905 happy to accept pull requests or even simple findings here in the ticket. I'm just updating my Windows Emacs to 29.3 now and will test a bit + see how it behaves on my Macbook.

@guidoschmidt
Copy link
Owner

guidoschmidt commented Apr 17, 2024

I found something interesting, it seems that Emacs' run-at-time function, passed "18:00" will run right away even if it is now 18:00:59!

That may or may not be related.

If it is, the source of the error must be that circadian is re-scheduling the same theme until the clock is definitely greater. I propose changing the little <= inside circadian-a-earlier-b-p to a <. I haven't tested if that makes a difference yet. I don't always get the bug in the first place, so it'd be good if someone else can say if it makes a difference.

Ok changing this to < only here

(<= (cl-second time-a) (cl-second time-b)))
let the tests fail, so that's clearly not the right thing unfortunatelly.

I also couldn't yet reproduce high CPU usage on my macOS system 😢 ... I think we first need to find a reliable way to reproduce this bug (+ which Emacs version on which OS)

@guidoschmidt
Copy link
Owner

guidoschmidt commented Apr 19, 2024

Indeed it looks like circadian-activate-latest-theme is running for a whole minute. A simple print statement illustrates it 95e934fce4af7042e00c5c04f2da7c76d20ce6f4 quite easily.

@guidoschmidt guidoschmidt self-assigned this Apr 19, 2024
@guidoschmidt guidoschmidt added this to the 0.4.0 milestone Apr 19, 2024
guidoschmidt added a commit that referenced this issue Apr 19, 2024
@guidoschmidt guidoschmidt linked a pull request Apr 19, 2024 that will close this issue
guidoschmidt added a commit that referenced this issue Apr 20, 2024
* EDIT/circadian.el: add print statement to circadian-activate-latest-theme

* FIX: potential fix for #28

* FIX/test.el: move timezone test to end

* EDIT/.github/workflows/ci.yml: drop Emacs 26.3 support

* EDIT/circadian.el: moved check for already enabled theme from `circadian-enable-theme` to `circadian-activate-latest-theme`

* EDIT: cleanup
@madanyang
Copy link

madanyang commented Apr 25, 2024

Your last release reintroduced the freeze with Emacs 29.3. Other than using a kill command, nothing is possible via Emacs mini buffer. There is a continues update about the next run time in the minibuffer making it unusable.

@meedstrom
Copy link

meedstrom commented Apr 26, 2024

It does not freeze for me. Emacs 30.0.50. Although it does complain about calendar-latitude and longitude, even though my circadian-themes sets the times explicitly, so I set latitude and longitude too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants