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

Only delay/wait for managed storage once on browser extension startup #7784

Closed
twschiller opened this issue Mar 1, 2024 · 3 comments · Fixed by #7790
Closed

Only delay/wait for managed storage once on browser extension startup #7784

twschiller opened this issue Mar 1, 2024 · 3 comments · Fixed by #7790
Assignees

Comments

@twschiller
Copy link
Contributor

twschiller commented Mar 1, 2024

Context

Considerations

Potential Implementation Approaches

  • On MV3, we could use the shared in-memory storage to set a flag saying that managed storage has been initialized / we’ve determined that it’s not set. That session storage gets reset automatically on profile startup
  • On MV2, we could have the context ping the background page for that information. That would be higher latency. There might be a way to track that in localStorage too — the background page on startup could:
    • Clear a chrome.local storage key
    • Wait for managed storage to be initialized
    • Set a chrome.local storage key indicating managed storage has been initialized/is unset
    • Calls to
      export const initManagedStorage = once(async () => {
      could check the flag/listen for changes to the flag to abort waiting the 4.5 seconds
@twschiller twschiller changed the title Only delay/wait for managed storage once Only delay/wait for managed storage once on browser extension startup Mar 1, 2024
@fungairino
Copy link
Collaborator

An example of a place where this latency is impacting the app:

const baseUrl = await getBaseURL();

Because it takes 4.5 seconds to check for the service url, the datadog rum library isnt initialized fast enough to cover the initial API calls to the service.

@fregante
Copy link
Collaborator

fregante commented Mar 2, 2024

What's in the managed storage? Can it always just be initialized later? i.e. just open the defaults/localStorage first and then update them once the managed storage is received, via hook if it affects a react app.

I don't know the ratio of users on/off managed storage, but this negatively affects users who are not on it (1s-4s if managed; full 4.5s if not managed)

@twschiller
Copy link
Contributor Author

twschiller commented Mar 2, 2024

What's in the managed storage? Can it always just be initialized later?

See keys here:

"managedOrganizationId": {

Unfortunately, we need managed storage because it's used to enforce branding and restrictions. I think the adjustment described in the implementation approaches will solve most of the problem. There will still be a 4.5s delay on initial startup, but that's generally not noticeable anyway because: 1) on install from CWS, it's unclear when the download finished vs. when the extension starts up, 2) on fresh browser profile startup there's generally other tabs/extensions popping up

The long-term solution will be: w3c/webextensions#547

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants