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

ar(fix) ThunderBird calendar slows after editing one CalDav entry: draft: watch events prop drain #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

angeloreale
Copy link

Context (REQUIRED):

This PR is being opened without local testing (to draft and test later, or for someone else to pickup with some reference).

Other than limiting the amount of events rendered by the returned CalDav source, another approach to solving this is to memoize the events as they're first received or locally stored, then use a SubPub pattern to trigger the update of the event metadata on-demand (user dragged, user resized event, user actually edited the event content), to re-render only the respective event.

  • AppleOS ThunderBird (Firefox)
  • 128.6.0esr 20250107005646
  • latest

Describe the bug (REQUIRED)

Currently, it seems like by watching the events prop, any update (visibility toggle, unsubscribe from calendar, update event details, etc.) triggers a re-render of the entire events prop dependency tree (whole calendar, every view, every mode, every event, etc).

When manipulating an event or any calendar with multiple events repeated to infinity, it creates a drain of time complexity that crashes Thunderbird entirely.

To Reproduce

Steps to reproduce the behavior:

  1. Add a few CalDav Calendars (e.g. 4)
  2. Add a few daily events (e.g. 10 events everyday at different times)
  3. Try to:
  • Edit one event;
  • Delete a recurring event;
  • Hide/Show calendar visibility;
  • Unsubscribe from calendars;
  1. At any, if not all, if as in my local environment, Thunderbird should freeze, even if temporarily, although in my Macbook, it usually crashes Thunderbird entirely.

Expected behavior

I modify one event.
UI shows the updated data immediately (re-renders only the modified event).
I take any other action in the calendar and its events (except a global update e.g. color).
Not every event should re-render, but only the affected ones.

Screenshots

  • e.g. I've just hidden the visibility of 1 out of 4 CalDav calendars, with a few dozen recurring events only, and it crashed the app (frozen for over 3 minutes, now unresponsive, might resolve after a few more minutes).
Screen.Recording.2025-01-23.at.02.10.37.mov

Additional context

This is my first PR with Thunderbird, it's under-tested, and I ask to pardon any imperfections. It's late here for me to make sure this PR works (setup local environment), but it might help shed some light to someone else with all the toolkit at hand.

How to test this PR**.

This PR is being opened without local testing (to draft and test later, or for someone else to pickup with some reference).

Comment on lines -194 to -209
events: {
deep: true,
handler(newVal, oldVal) {
// The check on strict equality as primitive values is needed,
// since we do not want to trigger a rerender on event-was-resized
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
this.eventsDataProperty = newVal;
this.eventRenderingKey = this.eventRenderingKey + 1;
}

if (this.config.isSilent) return;

this.events.forEach((e) => this.ErrorsHelper.checkEventProperties(e));
},
immediate: true,
},
Copy link
Author

Choose a reason for hiding this comment

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

This is a drainer.

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