Skip to content
GitLab
    • Why GitLab
    • Pricing
    • Contact Sales
    • Explore
  • Why GitLab
  • Pricing
  • Contact Sales
  • Explore
  • Sign in
  • Get free trial
  • Adblock inc Adblock inc
  • Extensions Extensions
  • Adblock Plus Adblock Plus
  • adblockplusuiadblockplusui
  • Issues
  • #1071

Handle unreliable timeouts/intervals

Background / User story

Manifest v3 forces us to run our background scripts in a service worker, which can be suspended/terminated at any time. Therefore we need to make sure that we can handle unreliable timeouts and intervals.

Note that the browser.alarms.* API that is meant to be used for those cases may not be reliable enough for all use cases:

  • https://bugs.chromium.org/p/chromium/issues/detail?id=471524
  • https://bugs.chromium.org/p/chromium/issues/detail?id=1245934

Potential breakage:

  • Ongoing icon animation doesn't finish.
  • Local first-run page doesn't open after remote first-run page fails to open.
  • Local first-run page opens after remote first-run page was opened.
  • Icon text doesn't update when blocked counter is incremented.
  • Day-1 notification isn't shown.
  • Total blocked counter isn't saved persistently.

What to change

  • Design: TBD
  • Research: TBD
  • Spec: TBD
  • Legal: TBD
  • Development:
    • Use browser.alarms.* API in the background page instead of window.setInterval() and window.setTimeout().
      • Intervals
        • lib/devenvPoller: doPoll() (functionality can be removed altogether)
        • lib/icon: animateIcon() (see #1190 (closed))
      • Timeouts
        • lib/filterComposer: doInit() (only applies to Firefox)
        • lib/init
          • listenForRemotePage()
          • wait() (inconsequential and not possible due to closure)
        • lib/notifications: initDay1Notification()
        • lib/prefs: customSave.set("blocked_total") (only applies to Firefox <66)
        • lib/stats: scheduleBadgeUpdate()
    • Do not use browser.alarms.* API for intervals/timeouts that are less than 60s (see comment).

Hints for testers

See list of potential breakage under "Background".

Hints for translators

N/A

Edited Jul 27, 2022 by Thomas Greiner
Assignee
Assign to
Time tracking