Skip to content

Make extension background non-persistent #44

@bershanskiy

Description

@bershanskiy

Describe the bug
Background page should not be persistent.

To Reproduce
Steps to reproduce the behavior:

  1. Install extension in Chrome and close all dev tools, including Svelte.
  2. Open Chrome Task manager (click Shift+ESC).
  3. See "Extension: Svelte Devtools" in the process list, even though extension is not in use.

Expected behavior
When extension is not in use, it should not consume computer resources (RAM).

Environment

  • Browser: Any (Chrome 91)
  • Devtools version: Any (built from master)
  • Svelte version: Any (3.38.2)

Additional context
If you are interested, I can file a PR to fix this. Right now, only Chrome supports non-persistent pages, but Firefox plans to add support soonTM.

Plan
I will break up this into a few PRs. Here is a tentative plan (no particular order):

WIP (all these are blocked on already opened PRs):

  1. (TODO) Store and retreive Background context variables from chrome.storage.local when needed
  2. (TODO) Optimization: let background open and close persistent ports with DevTools only when needed
  3. (TODO) Declare background non-persistent in manifest.json and test it!

Review:

  1. Avoid excessive chrome.tabs.onUpdated invocations #62
    Optimization: avoid chrome.tabs.onUpdated because it is triggered for every single other tab.
    Frequent callback runs restore background into active state unnecessarily.
  2. Send messages from DevTools to BG via one-time messages #60

Done:

  1. Avoid persistent ports in content scripts #54 Removes pagePorts in src/background.js
  2. Store profiler enabled/disabled state in inspected window's sessionStorage #53 Fix: background has two handlers for 'startProfiler' (one is dead) and no handler for 'stopProfiler'
  3. Store profiler enabled/disabled state in inspected window's sessionStorage #53 Get rid of gloal profilerEnabledList in src/background.js
    Value of this variable is set in DevTools tab and is used in content script. It makes sense to store it in either one, but not in background.

Edit: add plan!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions