1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-14 02:08:50 +02:00
The browser extension vault (Chrome, Firefox, Opera, Edge, Safari, & more).
Go to file
Addison Beck ccd715d7b8
[Bug] [Account Switching] Improve State Management Performance (#611)
* [bug] Improve state management performance

Large vaults see a clear degrade in performance using the state service, especially when multiple vaults are authed and unlocked at the same time.

Some changes made to address this:
1. Clearing in memory decrypted data for non active accounts. This really should have been something we were doing anyway, but letting go of that memory burden has a noticable performance boost.
2. Not loading a bunch of unecsassary data from disk accounts into memory on application startup. This was being done to initilize in memory accounts, but brought a lot of extra baggage with it like storing encrypted data in memory, even though it is never referenced that way.
3. Breaking the on disk state object up into seperate keys for accounts instead of storing everything together under a "state" key. This ensures there is less information fetched from disk each time we call for an account.

There were some restructuring changes needed to facilitate these items:
1. We need to be able to construct an account in the StateService, but typescript doesn't allow for new() constraints on generics so a factory needs to be created and passed into the StateService for this to work.
2. Since we can't reference an all-knowing "accounts" object for on disk state anymore we have to maintain a list of authenticated accounts, and this has been added.
3. The StateMigration service needed to be updated to break up the accounts object, so current dev and QA state will be broken and need to be reset.

Some other general refactorings that were helpful gettings this working:
1. Added a constant for keys to the StateService and StateMigrationService.
2. Bundling everything needed to deauthenticate a user into a dedicated method.
3. Bundling all the disk storage clear methods (that should be refactored later into client specific state services) into one helper method.
4. Bundling everything needed to dynamically select a new active user into a dedicated method.

* [bug] Set environmentUrls appropriatly on account add

* [bug] Stop tracking activity without an active user

* [bug] Remove lastActive from globalState and globalState migration

* [style] Ran prettier
2022-01-19 10:51:10 -05:00
.github Apply Prettier (#581) 2021-12-16 13:36:21 +01:00
.husky Add Prettier configuration (#574) 2021-12-16 12:45:01 +01:00
.vscode Apply Prettier (#581) 2021-12-16 13:36:21 +01:00
angular [Bug] [Account Switching] Improve State Management Performance (#611) 2022-01-19 10:51:10 -05:00
common [Bug] [Account Switching] Improve State Management Performance (#611) 2022-01-19 10:51:10 -05:00
electron Bump electron from 16.0.2 to 16.0.7 (#613) 2022-01-17 17:27:14 +01:00
node Add a shared tsconfig file (#609) 2022-01-17 13:21:20 +01:00
shared Add a shared tsconfig file (#609) 2022-01-17 13:21:20 +01:00
spec Fix for issue #1287 in bitwarden/web (#569) 2021-12-16 18:46:33 +01:00
.editorconfig Add Prettier configuration (#574) 2021-12-16 12:45:01 +01:00
.git-blame-ignore-revs Add .git-blame-ignore-revs and prettier instructions (#585) 2021-12-16 14:10:11 +01:00
.gitattributes Apply Prettier (#581) 2021-12-16 13:36:21 +01:00
.gitignore setup karma testing 2018-04-17 16:15:19 -04:00
.prettierignore Fix prettier (#598) 2022-01-07 14:23:42 +01:00
.prettierrc.json Add Prettier configuration (#574) 2021-12-16 12:45:01 +01:00
CONTRIBUTING.md Apply Prettier (#581) 2021-12-16 13:36:21 +01:00
LICENSE.txt license and contrib 2018-01-26 16:07:38 -05:00
package-lock.json Bump electron from 16.0.2 to 16.0.7 (#613) 2022-01-17 17:27:14 +01:00
package.json Fix prettier (#598) 2022-01-07 14:23:42 +01:00
README.md Update README.md (#586) 2021-12-16 14:38:11 +01:00
SECURITY.md Apply Prettier (#581) 2021-12-16 13:36:21 +01:00
tsconfig.json Apply Prettier (#581) 2021-12-16 13:36:21 +01:00
tslint.json Apply Prettier (#581) 2021-12-16 13:36:21 +01:00

Github Workflow build on master

Bitwarden JavaScript Library

Common code referenced across Bitwarden JavaScript projects.

Requirements

  • Node.js v16.13.1 or greater
  • NPM v8
  • Git
  • node-gyp

Windows

  • Microsoft Build Tools 2015 in Visual Studio Installer
  • Windows 10 SDK 17134 either by downloading it seperately or through the Visual Studio Installer.

Prettier

We recently migrated to using Prettier as code formatter. All previous branches will need to updated to avoid large merge conflicts using the following steps:

  1. Check out your local Branch
  2. Run git merge 8b2dfc6cdcb8ff5b604364c2ea6d343473aee7cd
  3. Resolve any merge conflicts, commit.
  4. Run npm run prettier
  5. Commit
  6. Run git merge -Xours 193434461dbd9c48fe5dcbad95693470aec422ac
  7. Push

Git blame

We also recommend that you configure git to ignore the prettier revision using:

git config blame.ignoreRevsFile .git-blame-ignore-revs