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 10 commits into
base: main
Choose a base branch
from
Open

Load-sdk-once #12764

wants to merge 10 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 & Detailse7b45fd3-dc4c-475f-a88e-e97bb6392135

Great job, no security vulnerabilities found in this Pull Request

@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?

@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.

@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.28%. Comparing base (6f018e1) to head (e62194e).

✅ 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.27%   34.28%           
=======================================
  Files        2935     2939    +4     
  Lines       90232    90261   +29     
  Branches    16943    16948    +5     
=======================================
+ Hits        30931    30947   +16     
- Misses      56837    56849   +12     
- Partials     2464     2465    +1     

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

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.
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.
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