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

Load-sdk-once #12764

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Load-sdk-once #12764

wants to merge 9 commits into from

Conversation

MGibson1
Copy link
Member

@MGibson1 MGibson1 commented Jan 8, 2025

📔 Objective

Current SDK loading occurs only when an sdk client is requested. However, ssh key generation uses a pure function to generate ED25519 keys which does not require a client. As dependency on the SDK increases, it is more appropriate to ensure the WASM module is loaded as a part of initialization than repeatedly when creating a client.

📸 Screenshots

The effect of slow wasm loading is to keep the page on the un-inited spinner state for longer:

web

Screen.Recording.2025-01-09.at.9.22.57.AM.mov

browser

Screen.Recording.2025-01-09.at.9.35.07.AM.mov

cli

Screen.Recording.2025-01-09.at.9.38.08.AM.mov

desktop

Screen.Recording.2025-01-09.at.9.57.37.AM.mov

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@MGibson1 MGibson1 requested a review from a team as a code owner January 8, 2025 22:18
@MGibson1 MGibson1 requested review from coroiu and Hinton January 8, 2025 22:18
@MGibson1
Copy link
Member Author

MGibson1 commented Jan 8, 2025

@Hinton one of the things that gives me pause about adding this to init services is that you'd seen long wasm load times in some of our userbase. However, I saw you recently removed the logging there. Is everything good to go? Hopefully no more concerns about loading that module?

Copy link
Contributor

github-actions bot commented Jan 8, 2025

Logo
Checkmarx One – Scan Summary & Details649ded95-32da-4df9-9ab5-af8718eed761

New Issues (8)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Angular_Improper_Type_Pipe_Usage /apps/browser/src/autofill/popup/fido2/fido2-use-browser-link-v1.component.html: 1
detailsThe value used in fido2PopoutSessionData$ at /apps/browser/src/autofill/popup/fido2/fido2-use-browser-link-v1.component.html in line 1 may throw an...
Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/vault/popup/components/vault-v2/vault-list-items-container/vault-list-items-container.component.html: 15
detailsMethod at line 15 of /apps/browser/src/vault/popup/components/vault-v2/vault-list-items-container/vault-list-items-container.component.html sends ...
Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/popup/settings/autofill-v1.component.ts: 104
detailsMethod AutofillV1Component at line 104 of /apps/browser/src/autofill/popup/settings/autofill-v1.component.ts sends user information outside the app...
Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/popup/settings/notifications-v1.component.ts: 32
detailsMethod ngOnInit at line 32 of /apps/browser/src/autofill/popup/settings/notifications-v1.component.ts sends user information outside the applicatio...
Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/popup/settings/autofill-v1.component.ts: 104
detailsMethod AutofillV1Component at line 104 of /apps/browser/src/autofill/popup/settings/autofill-v1.component.ts sends user information outside the app...
Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/popup/fido2/fido2-cipher-row-v1.component.ts: 12
detailsMethod app_fido2_cipher_row_v1 at line 12 of /apps/browser/src/autofill/popup/fido2/fido2-cipher-row-v1.component.ts sends user information outside...
Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/popup/fido2/fido2-cipher-row-v1.component.ts: 12
detailsMethod app_fido2_cipher_row_v1 at line 12 of /apps/browser/src/autofill/popup/fido2/fido2-cipher-row-v1.component.ts sends user information outside...
Attack Vector
MEDIUM Client_Privacy_Violation /apps/browser/src/autofill/popup/fido2/fido2-cipher-row-v1.component.ts: 12
detailsMethod app_fido2_cipher_row_v1 at line 12 of /apps/browser/src/autofill/popup/fido2/fido2-cipher-row-v1.component.ts sends user information outside...
Attack Vector
Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM Client_Privacy_Violation /bitwarden_license/bit-web/src/app/tools/access-intelligence/org-at-risk-members-dialog.component.html: 17

@Hinton
Copy link
Member

Hinton commented Jan 9, 2025

@MGibson1 We still saw some long loads but our theory is the machine is busy doing other things and haven't gotten back to continuing the wasm load. There are logging statements in place to assist in tracking this down should we receive reports from users.

This seems like it's replacing the factories with loaders, can we remove the factories, the initialization step should be identical across environment with these changes?

Note: If the main process ever requires an SDK, we'll need to load it there, too.
In that event, it's probably a good idea to move to IPC for all SDK functions to avoid
loading the SDK for every window.
@MGibson1 MGibson1 marked this pull request as draft January 9, 2025 23:59
@MGibson1
Copy link
Member Author

This seems like it's replacing the factories with loaders, can we remove the factories, the initialization step should be identical across environment with these changes?

I wasn't sure about this since the web is calling a global function that for some reason was ensuring the module was inited again. These changes have now been pushed here.

A CLI sdk load service that async imports our wasm binary doesn't seem to be needed to run, but jest isn't dealing with the ESM import properly.
@MGibson1 MGibson1 marked this pull request as ready for review January 13, 2025 18:41
Copy link

codecov bot commented Jan 13, 2025

Codecov Report

Attention: Patch coverage is 27.53623% with 50 lines in your changes missing coverage. Please review.

Project coverage is 34.27%. Comparing base (16a0176) to head (c8a4e27).
Report is 59 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../platform/services/sdk/browser-sdk-load.service.ts 0.00% 10 Missing ⚠️
apps/web/src/app/platform/web-sdk-load.service.ts 61.53% 5 Missing ⚠️
apps/browser/src/background/main.background.ts 0.00% 4 Missing ⚠️
apps/browser/src/popup/services/services.module.ts 0.00% 4 Missing ⚠️
apps/desktop/src/app/services/services.module.ts 0.00% 4 Missing ⚠️
.../platform/services/sdk/default-sdk-load.service.ts 0.00% 4 Missing ⚠️
apps/browser/src/popup/services/init.service.ts 0.00% 3 Missing ⚠️
apps/desktop/src/app/services/init.service.ts 0.00% 3 Missing ⚠️
...src/platform/services/sdk/noop-sdk-load.service.ts 0.00% 3 Missing ⚠️
apps/browser/src/platform/services/sdk/fallback.ts 0.00% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12764      +/-   ##
==========================================
+ Coverage   34.14%   34.27%   +0.13%     
==========================================
  Files        2937     2937              
  Lines       90337    90108     -229     
  Branches    16961    16921      -40     
==========================================
+ Hits        30846    30886      +40     
+ Misses      57036    56763     -273     
- Partials     2455     2459       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

Successfully merging this pull request may close these issues.

2 participants