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

UX: Load the extension HTML pages and background with async JavaScript #20843

Merged
merged 10 commits into from
Sep 22, 2023

Conversation

darkwing
Copy link
Contributor

Explanation

At present the loading of both the fullscreen view and MetaMask popup are really slow due to the loading of ~15-20 synchronous JavaScript files in home.html, popup.html, and notification.html. Our users experience this slowness most notably when clicking on the MetaMask icon in the extensions toolbar -- the click happens, then nothing for seemingly 1-2 seconds, and then the popup finally renders the user's wallet.

This PR loads both the UI and background scripts (1) sequentially and (2) asynchronously, drastically improving perceived performance. Now when clicking the MetaMask extension icon, the popup displays immediately, shows a spinner while the scripts load, and then load in the UI.

Screenshots/Screencaps

FastLoad.mov

Manual Testing Steps

  1. Pull down this PR
  2. yarn start
  3. Click the MetaMask logo in the extension toolbar
  4. See the popup display very quickly, showing the MetaMask head and spinner, and roughly 1 second later the extension displays and functions as normal
  5. Open the fullscreen view, see it load and work as normal

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@darkwing darkwing requested review from kumavis and a team as code owners September 12, 2023 18:33
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@darkwing darkwing added team-extension-ux DEPRECATED: please use "team-wallet-ux" label instead needs-ux-ds-review labels Sep 12, 2023
@darkwing darkwing force-pushed the async-load-app branch 2 times, most recently from 70358b6 to ab73693 Compare September 13, 2023 19:18
@darkwing darkwing force-pushed the async-load-app branch 2 times, most recently from 45b8562 to ccef0c8 Compare September 19, 2023 12:34
@darkwing darkwing requested review from a team as code owners September 19, 2023 13:23
@darkwing darkwing force-pushed the async-load-app branch 3 times, most recently from e558a10 to 696c60c Compare September 19, 2023 16:16
@metamaskbot
Copy link
Collaborator

Builds ready [2554c62]
Page Load Metrics (633 ± 350 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint852671133818
domContentLoaded692631054120
load801857633730350
domInteractive692631054120
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@codecov
Copy link

codecov bot commented Sep 21, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (7dbb8c8) 68.40% compared to head (c61c0c8) 68.40%.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #20843   +/-   ##
========================================
  Coverage    68.40%   68.40%           
========================================
  Files         1006     1006           
  Lines        40218    40218           
  Branches     10758    10758           
========================================
  Hits         27508    27508           
  Misses       12710    12710           

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

@metamaskbot
Copy link
Collaborator

Builds ready [c61c0c8]
Page Load Metrics (1856 ± 72 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint881641252412
domContentLoaded721631182612
load16352148185614972
domInteractive721621182612
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Member

@kumavis kumavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hell yes

applyLavaMoat,
isMMI: buildType === 'mmi',
});
renderJavaScriptLoader({
groupSet,
commonSet,
browserPlatforms,
applyLavaMoat,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok to remove the mmi line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately not because of this code in the home.html file:

{{@if(it.isMMI)}}
    <title>MetaMask Institutional</title>
{{/if}}

@darkwing darkwing merged commit b30b329 into develop Sep 22, 2023
9 checks passed
@darkwing darkwing deleted the async-load-app branch September 22, 2023 19:09
@github-actions github-actions bot locked and limited conversation to collaborators Sep 22, 2023
@metamaskbot metamaskbot added the release-11.3.0 Issue or pull request that will be included in release 11.3.0 label Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-11.3.0 Issue or pull request that will be included in release 11.3.0 team-extension-ux DEPRECATED: please use "team-wallet-ux" label instead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants