Skip to content

Conversation

@brad-decker
Copy link
Contributor

@brad-decker brad-decker commented Jan 30, 2024

Description

The work done in the proceeding offscreen PRs was done explicitly to hopefully make adopting the snaps executor written for offscreen support without much additional effort. This PR is not complete because it has a type error but sharing the code changes now.

This PR pulls forward the ProxySnapsExecutor from the snaps-execution-environments repository and initializes it with a runtime message stream. This allows the snaps executor to communicate through the offscreen document and enable support for snaps in MV3

Related issues

MetaMask-planning#1998

Manual testing steps

  1. Pull branch
  2. run yarn
  3. run yarn start:mv3
  4. Go to https://metamask.github.io/snaps/test-snaps/latest/
  5. Install some of the snaps by clicking "reconnect to X"
  6. Interact with the buttons after installing snap and see they work.

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@@ -17,3 +18,5 @@ const parentStream = new BrowserRuntimePostMessageStream({
parentStream.on('data', (data) => {
console.log('Offscreen Document received data from service worker', data);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line should probably be removed in this PR because the stream now receives messages from snaps! However, its helpful to keep right up until we have validated the approach.

@@ -1,4 +1,5 @@
import { BrowserRuntimePostMessageStream } from '@metamask/post-message-stream';
import { ProxySnapExecutor } from '@metamask/snaps-execution-environments/dist/cjs/proxy/ProxySnapExecutor';
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 will need to write a .d.ts file to type this or somehow point the import to the types exported for this class from the package

@socket-security
Copy link

socket-security bot commented Jan 30, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/snaps-execution-environments@4.0.1 Transitive: environment, filesystem, network, shell, unsafe +134 41.3 MB metamaskbot

View full report↗︎

@socket-security
Copy link

socket-security bot commented Jan 30, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎


const snapExecutionServiceArgs = {
iframeUrl: new URL(process.env.IFRAME_EXECUTION_ENVIRONMENT_URL),
[shouldUseOffscreenExecutionService ? 'frameUrl' : 'iframeUrl']: new URL(
Copy link
Member

Choose a reason for hiding this comment

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

frameUrl is no longer a constructor argument for OffscreenExecutionService. Instead the URL is hardcoded and tied to the version of the executor package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@FrederikBolding so i need to just conditionally add the 'iframeUrl' parameter for the IframeExecutionService?

Copy link
Member

Choose a reason for hiding this comment

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

What you did now looks fine to me! 👍

@codecov
Copy link

codecov bot commented Jan 30, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 68.61%. Comparing base (40f281b) to head (a6004dc).

Files Patch % Lines
app/scripts/metamask-controller.js 72.73% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #22732      +/-   ##
===========================================
+ Coverage    68.60%   68.61%   +0.01%     
===========================================
  Files         1096     1096              
  Lines        43253    43240      -13     
  Branches     11525    11531       +6     
===========================================
- Hits         29672    29668       -4     
+ Misses       13581    13572       -9     

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

@metamaskbot
Copy link
Collaborator

Builds ready [12db2c4]
Page Load Metrics (843 ± 32 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint90152115157
domContentLoaded115319105
load7459968436732
domInteractive115319105
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 195 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@brad-decker brad-decker added the team-extension-platform Extension Platform team label Jan 31, 2024
@brad-decker
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@metamaskbot
Copy link
Collaborator

Builds ready [05993e0]
Page Load Metrics (767 ± 38 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint831811122613
domContentLoaded9481684
load6889807678038
domInteractive9481684
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -175 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@brad-decker brad-decker marked this pull request as ready for review January 31, 2024 22:39
@brad-decker brad-decker requested review from a team as code owners January 31, 2024 22:39
@brad-decker brad-decker requested review from a team and kumavis as code owners February 2, 2024 14:36
@metamaskbot
Copy link
Collaborator

Builds ready [ac6a733]
Page Load Metrics (713 ± 11 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint92130102105
domContentLoaded9231531
load6827737132411
domInteractive9231531
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -175 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

FrederikBolding
FrederikBolding previously approved these changes Feb 7, 2024
@brad-decker
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@metamaskbot
Copy link
Collaborator

Builds ready [71825f6]
Page Load Metrics (806 ± 47 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint831681092010
domContentLoaded11552194
load71011008069947
domInteractive11552194
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -314 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: -41.92 KiB (-0.83%)

@metamaskbot
Copy link
Collaborator

Builds ready [8bde090]
Page Load Metrics (834 ± 27 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint801591122010
domContentLoaded105519126
load7399378345627
domInteractive105519126
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -314 Bytes (-0.01%)
  • ui: 0 Bytes (0.00%)
  • common: -41.92 KiB (-0.83%)

@brad-decker brad-decker force-pushed the feat/snaps-mv3-support branch from 8bde090 to 8019c7b Compare February 13, 2024 17:51
@brad-decker
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@metamaskbot
Copy link
Collaborator

Builds ready [1dd3b5a]
Page Load Metrics (1003 ± 49 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1252631893517
domContentLoaded10154343517
load9011295100310349
domInteractive10154343517
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 15.43 KiB (0.45%)
  • ui: 0 Bytes (0.00%)
  • common: -40.8 KiB (-0.81%)

@brad-decker
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@metamaskbot
Copy link
Collaborator

Builds ready [7ac3c86]
Page Load Metrics (947 ± 45 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1162161693316
domContentLoaded983352713
load73912299479445
domInteractive983352713
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.04 KiB (-0.03%)
  • ui: 0 Bytes (0.00%)
  • common: -41.92 KiB (-0.83%)

weizman
weizman previously approved these changes Feb 18, 2024
Copy link
Contributor

@weizman weizman left a comment

Choose a reason for hiding this comment

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

lgtm

@metamaskbot
Copy link
Collaborator

Builds ready [da7cf87]
Page Load Metrics (1128 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1222571943416
domContentLoaded1184442412
load9181308112811455
domInteractive1184442412
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.04 KiB (-0.03%)
  • ui: 0 Bytes (0.00%)
  • common: -41.92 KiB (-0.83%)

@metamaskbot
Copy link
Collaborator

Builds ready [7ab4230]
Page Load Metrics (1073 ± 48 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1312741974421
domContentLoaded9103423014
load8611299107310148
domInteractive9103423014
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -1.04 KiB (-0.03%)
  • ui: 0 Bytes (0.00%)
  • common: -41.92 KiB (-0.83%)

@brad-decker
Copy link
Contributor Author

@SocketSecurity ignore npm/@metamask/post-message-stream@8.0.0

@brad-decker brad-decker dismissed stale reviews from FrederikBolding and weizman via 4cff51e February 22, 2024 18:57
@brad-decker brad-decker force-pushed the feat/snaps-mv3-support branch from 7ab4230 to 4cff51e Compare February 22, 2024 18:57
@brad-decker
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@metamaskbot
Copy link
Collaborator

Builds ready [a35f8cc]
Page Load Metrics (1781 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1252321672914
domContentLoaded105425115
load14512237178115976
domInteractive105425115
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -175 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@brad-decker brad-decker force-pushed the feat/snaps-mv3-support branch from a35f8cc to 7fb66af Compare February 26, 2024 14:23
@brad-decker
Copy link
Contributor Author

@metamaskbot update-policies

@metamaskbot
Copy link
Collaborator

Policies updated

@metamaskbot
Copy link
Collaborator

Builds ready [a6004dc]
Page Load Metrics (1215 ± 403 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint671771193115
domContentLoaded116531168
load5419871215839403
domInteractive116531168
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -175 Bytes (-0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@brad-decker brad-decker merged commit 610f4a1 into develop Feb 27, 2024
@brad-decker brad-decker deleted the feat/snaps-mv3-support branch February 27, 2024 21:20
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
@metamaskbot metamaskbot added the release-11.13.0 Issue or pull request that will be included in release 11.13.0 label Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-11.13.0 Issue or pull request that will be included in release 11.13.0 team-extension-platform Extension Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants