Skip to content

notifications@cinnamon.org - Avoid redundant update_list calls during clear all#13704

Open
jsharpe1 wants to merge 1 commit intolinuxmint:masterfrom
jsharpe1:clear-all-notifications-performance
Open

notifications@cinnamon.org - Avoid redundant update_list calls during clear all#13704
jsharpe1 wants to merge 1 commit intolinuxmint:masterfrom
jsharpe1:clear-all-notifications-performance

Conversation

@jsharpe1
Copy link
Copy Markdown

Problem

When clearing all notifications, each notification.destroy() triggers the destroy signal handler, which calls update_list() individually. With N notifications, this results in N+1 calls to update_list(), each recalculating urgency, updating icons/labels, reordering children, and requesting a relayout. When the notification count gets high, there is a noticeable hang when it clears all notifications. 50 notifications took 6.5 seconds to clear (see screenshot below).

Fix

Added a _clearing flag that causes the destroy handler to skip update_list() during bulk clear. The single update_list() call at the end of _clear_all() handles final state. Wrapped in try/finally to guarantee the flag resets if a destroy call throws.

Testing

Tested on Cinnamon 6.6.7 by triggering 50 notifications and clearing all. Verified via Looking Glass:

** Before: **
image

** After: **
image

Also verified:

  • Clear all updates tray icon and count correctly
  • Individual notification dismiss still updates the list

@fredcw
Copy link
Copy Markdown
Contributor

fredcw commented Apr 12, 2026

what computer are you using? I have a 4 core ryzen3 and clearing 50 notifications takes about 150ms. There's a max of 20 notifications per app as well.

@jsharpe1
Copy link
Copy Markdown
Author

@fredcw This is on my laptop - CPU is 11th Gen Intel(R) Core(TM) i7-11370H @ 3.30GHz.

Out of curiosity, I ran the same test (generating 50 notifications and clearing all) on my desktop, and did not have the same performance issue. That's running a 13th Gen Intel(R) Core(TM) i5-13600KF.

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.

2 participants