third-stats icon indicating copy to clipboard operation
third-stats copied to clipboard

Periodic Processing too often

Open devmount opened this issue 3 years ago • 6 comments
trafficstars

Describe the bug

image

To Reproduce Steps to reproduce the behavior:

  1. Update to ThirdStats 1.9.0 after updating to this version
  2. Open add-on options
  3. See automatic processing being set to only 5min

Expected behavior Set automatic processing to 6h

Screenshots None

Additional context None

devmount avatar Sep 16 '22 04:09 devmount

Thinking about it more, and how the value of thirdstats is likely proportional to mail store size, I'm going to up my recommended default time to 24 hours (once a day).

koobs avatar Sep 16 '22 04:09 koobs

The automatic background processing is a timer which starts when opening the stats page and is only active as long as the stats page is open. So 24h means you'd have to have your stats page open 24h.

Given that, I think 6h is just fine to reprocess the data at least once on a working day.

devmount avatar Sep 16 '22 10:09 devmount

The automatic background processing is a timer which starts when opening the stats page

Not possible to register a timer on extension load/init, independent of whether stats is open or not?

koobs avatar Sep 17 '22 00:09 koobs

In fact it should be possible setting the timer in the background.js, but only if you find a way to call the reprocessing function from outside the Vue instance... I didn't look into that yet, but I'll see what I can do.

devmount avatar Sep 17 '22 03:09 devmount

Referencing here findings & summary notes (with links and quotes in context) of ~2 hours of research re Thunderbird and Timers. Hope it saves you some time :)

tldr appears to be:

  • nsItimer
  • setTimeout()
  • Experiments API ( + wrappers)

Search: nsITimer (is XPCOM)

AdBlockPlus Issue 7375 - Replace Ci.nsITimer with setTimeout()

  • https://github.com/adblockplus/adblockpluscore/commit/6298d9bdb29d20f43e1a41e5fccc57c70891d7d1
  • https://issues.adblockplus.org/ticket/7375

TorBrowser: Investigate new WebExtensions API requirements for our extensions

  • https://gitlab.torproject.org/tpo/applications/tor-browser/-/issues/17248

WA7: Timers: Current Solution: nsITimer with TYPE_ONE_SHOT New Solution: window.setTimeout(). Also look at chrome.alarms.*

Search setTimeout

  • https://developer.mozilla.org/en-US/docs/Web/API/setTimeout
    • https://developer.thunderbird.net/add-ons/mailextensions#webextension-scripts
    • Web API (if the browser compatibility chart lists Firefox, the API also works in Thunderbird)
  • https://developer.thunderbird.net/add-ons/mailextensions#experiment-apis
    • https://developer.thunderbird.net/add-ons/mailextensions/supported-webextension-api
    • As Thunderbird is based on Firefox, many of its WebExtension APIs

Search idle

  • https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/idle Idea:
[x] Automatic thirdstats processing
   [x] Only when idle (or locked)

Thunderbird 102 supporting addon: Quick Folders

  • https://github.com/RealRaven2000/QuickFolders/issues/283#issuecomment-1240476351

QuickFolders apparently supports 102 (issue above is performance issue on 102)

Update-Info from Mozilla: Version 102.2.2, first offered to channel users on September 7, 2022

    fixed: Accessing mail folders in profiles with many folders was slow
  • https://github.com/RealRaven2000/QuickFolders/

QuickFolders uses Timers (WindowListener/* & setTimeout (in quickfolders-interface.js)"

  • Code results: https://github.com/RealRaven2000/QuickFolders/search?q=timer
    • chrome/content/api/WindowListener/implementation.js
    • https://github.com/RealRaven2000/QuickFolders/blob/master/chrome/content/api/WindowListener/implementation.js#L280
    ...
      // async sleep function using Promise
      async sleep(delay) {
        let timer = Components.classes["@mozilla.org/timer;1"].createInstance(
          Components.interfaces.nsITimer
    ...
            Components.interfaces.nsITimer.TYPE_ONE_SHOT
  • WindowListener from https://github.com/thundernest/addon-developer-support
  • https://github.com/thundernest/addon-developer-support/wiki/Using-the-WindowListener-API-to-convert-a-Legacy-Overlay-WebExtension-into-a-MailExtension-for-Thunderbird-78
  • https://github.com/thundernest/addon-developer-support/blob/master/wrapper-apis/WindowListener/implementation.js

The WindowListener API may only be called from the background page.

koobs avatar Sep 18 '22 01:09 koobs

Wow thanks! I'll look into that.

devmount avatar Sep 18 '22 03:09 devmount