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

WIP: 14743 improve web app speed #17424

Closed
wants to merge 6 commits into from

Conversation

vojtatranta
Copy link
Contributor

Description

Attempt to improve loading speed of the Suite app by:

  • increasing cache-control for the build files to 30 days accross deployments
  • adding PreloadWebpackPlugin to preload chunks that are needed for app

Related Issue

Addresses: #14743 (comment)

Screenshots:

@vojtatranta vojtatranta changed the title 14743 improve web app speed WIP: 14743 improve web app speed Mar 5, 2025
@vojtatranta vojtatranta marked this pull request as draft March 5, 2025 15:02
Copy link

github-actions bot commented Mar 5, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

Copy link

coderabbitai bot commented Mar 5, 2025

Walkthrough

The pull request includes updates across deployment workflows and build configurations. Two GitHub Actions workflows have been modified to add a cache-control header (max-age=2592000) to the AWS S3 sync commands, ensuring that files are cached for 30 days. Additionally, the Webpack configuration for the web client now integrates the PreloadWebpackPlugin to prefetch asynchronous JavaScript chunks, with specific inclusion and exclusion patterns for file types. The ESLint configuration is updated to exempt the new PreloadWebpackPlugin dependency from extraneous dependency checks. Finally, the package manifest for the suite-build package adds the @vue/preload-webpack-plugin dependency with a version constraint of ^2.0.0, which supports the build optimization introduced in the Webpack configuration.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/suite-build/configs/web.webpack.config.ts (2)

12-12: Consider using ES imports for consistency.

The codebase uses ES imports for other dependencies, but CommonJS require for the PreloadWebpackPlugin. For consistency, consider using ES import syntax if the plugin supports it.

-const PreloadWebpackPlugin = require('@vue/preload-webpack-plugin');
+import PreloadWebpackPlugin from '@vue/preload-webpack-plugin';

79-85: Consider standardizing property naming to avoid future deprecation issues.

The plugin is using fileWhitelist and fileBlacklist properties, but newer versions of similar plugins often use more inclusive terminology like include/exclude or includeFiles/excludeFiles.

While the current implementation works, it's worth noting that future versions might deprecate these property names. Consider documenting this in a comment or planning for eventual updates.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9ceb675 and dacdbc2.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • .github/workflows/release-suite-desktop-web-staging.yml (1 hunks)
  • .github/workflows/test-transport.yml (1 hunks)
  • packages/suite-build/configs/web.webpack.config.ts (2 hunks)
  • packages/suite-build/eslint.config.mjs (1 hunks)
  • packages/suite-build/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: PR-check / node-authorizeCoinjoin cancelCoinjoinAuthorization passphrase unlockPath setBusy checkFirmwareAuthenticity keepSession cancel.test info.test resetDevice-api
  • GitHub Check: PR-check / node-override init-api-flaky
  • GitHub Check: PR-check / web-authorizeCoinjoin cancelCoinjoinAuthorization passphrase unlockPath setBusy checkFirmwareAuthenticity keepSession cancel.test info.test resetDevice-api
  • GitHub Check: PR-check / web-override init-api-flaky
  • GitHub Check: build-deploy
  • GitHub Check: build-deploy
  • GitHub Check: run-desktop-tests (@group=wallet, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: run-desktop-tests (@group=other, trezor-user-env-unix)
  • GitHub Check: run-desktop-tests (@group=passphrase, trezor-user-env-unix)
  • GitHub Check: EAS Update
  • GitHub Check: run-desktop-tests (@group=settings, trezor-user-env-unix bitcoin-regtest)
  • GitHub Check: transport-e2e-test
  • GitHub Check: test
  • GitHub Check: run-desktop-tests (@group=device-management, trezor-user-env-unix)
  • GitHub Check: build-web
  • GitHub Check: Setup and Cache Dependencies
  • GitHub Check: run-desktop-tests (@group=suite, trezor-user-env-unix)
  • GitHub Check: Analyze with CodeQL (javascript)
  • GitHub Check: Socket Security: Pull Request Alerts
🔇 Additional comments (5)
.github/workflows/test-transport.yml (1)

108-111: Enhanced Caching with Updated Cache-Control Header

The updated aws s3 sync command now includes the --cache-control "max-age=2592000" option. This ensures that files are cached for 30 days, aligning well with the PR objective to improve loading speed. Please verify that this extended caching does not interfere with the immediate visibility of critical updates if deployments are frequent.

.github/workflows/release-suite-desktop-web-staging.yml (1)

133-137: Consistent Cache-Control Implementation in S3 Upload

The modification to the aws s3 sync command by adding --cache-control "max-age=2592000" ensures that the suite-desktop artifacts are cached for 30 days, matching the caching strategy in other workflows. This consistency is beneficial for performance improvements. Consider if any cache invalidation mechanisms are needed in case of urgent updates.

packages/suite-build/package.json (1)

28-28:

❓ Verification inconclusive

Dependency added correctly for webpack preloading feature.

The @vue/preload-webpack-plugin is a solid choice for implementing resource preloading, which should improve web app performance by prefetching critical JavaScript chunks.


🌐 Web query:

What is the latest version of @vue/preload-webpack-plugin?

Error during web search


Action Required: Verify Dependency Version for Preload Webpack Plugin

The dependency is added correctly in the file (packages/suite-build/package.json, line 28) with the version set to ^2.0.0. This version appears to be a solid choice for implementing resource preloading and should help improve web app performance by prefetching critical JavaScript chunks. However, the latest version information could not be retrieved due to a web query error. Please manually verify on the npm registry that ^2.0.0 reflects the most up-to-date release of @vue/preload-webpack-plugin.

packages/suite-build/eslint.config.mjs (1)

17-17: ESLint configuration updated appropriately.

Adding the @vue/preload-webpack-plugin to the allowed dependencies list in the ESLint configuration ensures that imports of this package won't trigger linting errors.

packages/suite-build/configs/web.webpack.config.ts (1)

79-85:

❓ Verification inconclusive

Preload configuration looks well-optimized.

The plugin configuration is well thought out:

  • Using rel: 'prefetch' is appropriate for non-critical resources that will be needed for future navigation
  • Focusing on async chunks is efficient as they're loaded on demand
  • The whitelist/blacklist patterns are sensible to target only JavaScript files while excluding less critical resources

This implementation should help improve the app's loading speed as intended.

To ensure the preloading strategy is effective, I recommend monitoring the performance impact after deployment using tools like Lighthouse or WebPageTest. You might want to verify which chunks are being prefetched with:


🏁 Script executed:

#!/bin/bash
# Check the generated HTML to see which resources are being prefetched
npm run build:web
grep -r "prefetch" packages/suite-web/build/

Length of output: 457


Manual Verification Required: Validate Prefetch Behavior

The preload configuration looks well-optimized. The settings for rel: 'prefetch', limiting to async chunks, and using targeted whitelist/blacklist patterns to select only JavaScript files are appropriate, which should help improve the app's loading speed.

However, the automated check using the suggested shell script did not yield any output because the npm run build:web script is missing and the expected build output directory (packages/suite-web/build/) was not found. I recommend manually verifying that the intended async chunk files are being prefetched by:

  • Running the correct build command for your web package.
  • Inspecting the final generated HTML to confirm the presence of prefetch links.
  • Monitoring performance post-deployment using tools like Lighthouse or WebPageTest.

@@ -133,7 +133,7 @@ jobs:
- name: Upload suite-desktop to staging-data.trezor.io canary
# uploads the files to the staging bucket canary folder (canary does not have staging percentage set)
run: |
aws s3 sync --delete ./trezor-suite-files s3://staging-data.trezor.io/suite/releases/desktop/canary
aws s3 sync --delete ./trezor-suite-files s3://staging-data.trezor.io/suite/releases/desktop/canary --cache-control "max-age=2592000"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess these won't be the files....

It would be better to set cache control more granulary eg. for just particular js. files that include a specific string (are unique - generated with webpack with some proper content hash)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vdovhanych is the person who knows, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vdovhanych is the person who knows, right?

@vojtatranta vojtatranta force-pushed the 14743-improve-web-app-speed branch from dacdbc2 to eff6fbd Compare March 6, 2025 09:45
@vojtatranta vojtatranta force-pushed the 14743-improve-web-app-speed branch 2 times, most recently from b722e42 to 2ba834a Compare March 6, 2025 10:39
@vojtatranta vojtatranta force-pushed the 14743-improve-web-app-speed branch from 2ba834a to 31fa546 Compare March 6, 2025 10:46
@vojtatranta vojtatranta closed this Mar 6, 2025
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.

1 participant