You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time the main view is redrawn, Mailpile adds a listener for ".mail_source" events in the EventLog. Mailpile never removes these listeners, so this is a memory leak.
Cause
Mailpile evals the following code every time the main view is redrawn:
Mailpile.Search.init(); contains the following line of code that subscribes to the ".mail_source" event:
EventLog.subscribe(".mail_source",function(ev){// bre: re-enabling this just for fun and to test the event subscription// code. This is broken in that it fails for non-English languages.if(ev.message.indexOf("Rescanning:")!=-1){$("#logo-bluemail").fadeOut(2000);$("#logo-redmail").hide(2000);$("#logo-greenmail").hide(3000);$("#logo-bluemail").fadeIn(2000);$("#logo-greenmail").fadeIn(4000);$("#logo-redmail").fadeIn(6000);}$('.status-in-title').attr('title',ev.data.name+': '+ev.message);});
Over time, EventLog.eventbindings fills with many subscribers from this call site.
Suggested Fix
Add code that checks for an existing subscription, and avoids resubscribing if one exists.
The text was updated successfully, but these errors were encountered:
Thank you for filing this. I agree with your analysis and I think you've done a great job describing the problem. 👍
To expand on how to fix; in shared-data/default-theme/html/jsapi/global/eventlog.js, there is a subscribe method which needs to be changed:
Add a third free-form ID string to subscriptions (a new argument)
Instead of a list of callbacks, use a dictionary/object keyed on the ID string.
If no ID is provided, generate a random one
The functions that work with the subscription list will need to be modified to iterate over the new object values, and any calls to EventLog.subscribe should be updated to add an ID (point 3. above will allow any old code that gets overlooked to continue working, albeit with the memory leak).
This design will allow prevention of duplicate registrations, while still allowing multiple parties to subscribe to the same events.
Problem
Every time the main view is redrawn, Mailpile adds a listener for ".mail_source" events in the EventLog. Mailpile never removes these listeners, so this is a memory leak.
Cause
Mailpile
evals
the following code every time the main view is redrawn:Mailpile.Search.init();
contains the following line of code that subscribes to the ".mail_source" event:Over time,
EventLog.eventbindings
fills with many subscribers from this call site.Suggested Fix
Add code that checks for an existing subscription, and avoids resubscribing if one exists.
The text was updated successfully, but these errors were encountered: