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

refactor(extension): set background script as non persistent and remove html template #570

Draft
wants to merge 2 commits into
base: update-manifest-v3
Choose a base branch
from

Conversation

lutangar
Copy link
Member

@lutangar lutangar commented Feb 3, 2020

background script do not use any persistent background feature, this was a legacy thing, this will definitely be a big take on performance improvement
https://developer.chrome.com/extensions/background_migration

@lutangar lutangar self-assigned this Feb 3, 2020
@MaartenLMEM
Copy link
Contributor

Looks fine. ^^

@JalilArfaoui
Copy link
Member

Nice catch !

But what about our periodic refreshs ? Shouldn’t we set an browser.alarms ? 

Also, it seems non-persistent background is not supported by Firefox yet :-(

image
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/background
(But that’s OK as it will just run in a persistent manner …)

@lutangar
Copy link
Member Author

lutangar commented Feb 6, 2020

But what about our periodic refreshs

@JalilArfaoui could you point me to the problematic lines?

@JalilArfaoui
Copy link
Member

But what about our periodic refreshs

@JalilArfaoui could you point me to the problematic lines?

In src/app/background/sagas/refreshMatchingContexts.ts and src/app/background/sagas/refreshContributors.ts for instance, we have :

    while (true) {
      yield delay(refreshInterval);
      yield call(refreshMatchingContexts);
    }

which I guess is implemented by setTimeout, which won’t work in non-persistant mode, if I understood correctly the documentation you pointed to …

@JalilArfaoui
Copy link
Member

We may have the same issue in src/app/background/sagas/lib/sendToTab.saga.ts …

@lutangar
Copy link
Member Author

lutangar commented Feb 6, 2020

Alright, nice catch, I'll look into it...

@lutangar
Copy link
Member Author

lutangar commented Feb 6, 2020

Well, let's forget about that for the time being, it's not that trival, and it need a new alarms permission.

Notes:
export const delay = (ms) => new Promise(res => // do alarm stuff here)
and
https://developer.mozilla.org/fr/docs/Mozilla/Add-ons/WebExtensions/API/alarms/create

@JalilArfaoui
Copy link
Member

Yep … Maybe for the coming refactor/clean phase …

@lutangar lutangar added help wanted 🖐 M 👕 Need some work / May have some uneasy points labels Jan 12, 2021
@lutangar lutangar removed their assignment Jan 12, 2021
@JalilArfaoui
Copy link
Member

@lutangar should we close this one ?

@lutangar
Copy link
Member Author

I think this would bring a significant performance boost (memory footprint) and might be easier on the cpu as well so I'd like to put this light. I'll might add a connected issue.

@lutangar
Copy link
Member Author

After some more investigation, switching to alarm might not be useful as in manifest v3 the background persistence thing seems to be deprecated... there might still be performant boost to take from switching to the alarms API tho.

This PR is still a WIP it'll require a bit more work to add some kind of alarm registry to make the onAlarm eventListener able to handle all alarms...

@lutangar lutangar marked this pull request as draft August 30, 2021 09:46
@lutangar lutangar force-pushed the refactor/non-persistent-background branch from 86cd64e to 0c0dd93 Compare June 14, 2024 13:50
@lutangar lutangar changed the base branch from master to update-manifest-v3 June 14, 2024 13:51
@lutangar lutangar requested a review from JalilArfaoui June 14, 2024 13:52
lutangar added 2 commits June 14, 2024 19:58
…ve html template

background script do not use any persistent background feature, this was a legacy thing, this will definitely be a big take on performance improvement
https://developer.chrome.com/extensions/background_migration

chore(manifest): fix
chore(manifest): fix
@lutangar lutangar force-pushed the refactor/non-persistent-background branch from 0c0dd93 to 9944748 Compare June 14, 2024 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants