Skip to content

Conversation

FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Oct 3, 2025

Description

Seemingly sharp is as efficient at optimizing GIFs as imagemin and doesn't have the same install-script problems on some systems that gifsicle brings. This PR proposes to use sharp for optimizing all images.

Needs a sanity check.

Open in GitHub Codespaces


Note

Replace imagemin/gifsicle with sharp for image optimization and remove related dependencies, updating configs and LavaMoat policies accordingly.

  • Development tooling:
    • development/optimize-media.mts: Use sharp exclusively for all image formats; remove imagemin/imagemin-gifsicle logic and imports.
  • Dependencies:
    • Remove imagemin, imagemin-gifsicle, and their @types from package.json; prune related entries from yarn.lock.
    • Update .depcheckrc.yml to drop imagemin* from ignored deps.
  • Security/Policies:
    • Update LavaMoat policies (lavamoat/browserify/*/policy.json, lavamoat/build-system/policy.json) to adjust package mappings (e.g., is-plain-obj path) and remove allowlist for imagemin-gifsicle>gifsicle.

Written by Cursor Bugbot for commit c6a9ae5. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added the team-core-platform Core Platform team label Oct 3, 2025
@FrederikBolding
Copy link
Member Author

@metamaskbot update-policies

@github-actions github-actions bot added the size-S label Oct 3, 2025
Copy link

socket-security bot commented Oct 3, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedkeyv@​3.0.0 ⏵ 3.1.0100 +110010095100

View full report

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Oct 3, 2025
@metamaskbot
Copy link
Collaborator

Policies updated.
👀 Please review the diff for suspicious new powers.

🧠 Learn how: https://lavamoat.github.io/guides/policy-diff/#what-to-look-for-when-reviewing-a-policy-diff

@metamaskbot
Copy link
Collaborator

✨ Files requiring CODEOWNER review ✨

🧩 @MetaMask/extension-devs (5 files, +5 -5)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +1 -1
      • 📁 experimental/
        • 📄 policy.json +1 -1
      • 📁 flask/
        • 📄 policy.json +1 -1
      • 📁 main/
        • 📄 policy.json +1 -1
    • 📁 build-system/
      • 📄 policy.json +1 -1

📜 @MetaMask/policy-reviewers (5 files, +5 -5)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +1 -1
      • 📁 experimental/
        • 📄 policy.json +1 -1
      • 📁 flask/
        • 📄 policy.json +1 -1
      • 📁 main/
        • 📄 policy.json +1 -1
    • 📁 build-system/
      • 📄 policy.json +1 -1

Tip

Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers.


🔗 @MetaMask/supply-chain (5 files, +5 -5)
  • 📁 lavamoat/
    • 📁 browserify/
      • 📁 beta/
        • 📄 policy.json +1 -1
      • 📁 experimental/
        • 📄 policy.json +1 -1
      • 📁 flask/
        • 📄 policy.json +1 -1
      • 📁 main/
        • 📄 policy.json +1 -1
    • 📁 build-system/
      • 📄 policy.json +1 -1

@metamaskbot
Copy link
Collaborator

📊 Page Load Benchmark Results

Current Commit: c6a9ae5 | Date: 10/3/2025

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.06s (±75ms) 🟡 | historical mean value: 1.05s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 739ms (±71ms) 🟢 | historical mean value: 740ms ⬇️ (historical data)
  • firstContentfulPaint-> current mean value: 76ms (±12ms) 🟢 | historical mean value: 80ms ⬇️ (historical data)
📈 Detailed Results
Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.06s 75ms 1.00s 1.35s 1.29s 1.35s
domContentLoaded 739ms 71ms 695ms 1.03s 959ms 1.03s
firstPaint 76ms 12ms 56ms 160ms 92ms 160ms
firstContentfulPaint 76ms 12ms 56ms 160ms 92ms 160ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms

Results generated automatically by MetaMask CI

@metamaskbot
Copy link
Collaborator

Builds ready [c6a9ae5]
UI Startup Metrics (1233 ± 78 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1233109914867812831369
load106691112937110991197
domContentLoaded105890212867210941191
domInteractive1913133131740
firstPaint761143124341510901194
backgroundConnect25423835114257268
firstReactRender23169182436
getState1355681527
initialActions606510722
loadScripts811667103769847939
setupStore96213915
WebpackHomeuiStartup20291543270126622042488
load16321242201520617871935
domContentLoaded16241232200520617811929
domInteractive171282101444
firstPaint1606344371178312
backgroundConnect3015347342869
firstReactRender88373356682319
getState2953116913275
initialActions7217617515
loadScripts16211230199320417791917
setupStore185308451319
FirefoxBrowserifyHomeuiStartup13951211190311514481593
load1201105814327912671321
domContentLoaded1201105814327912661320
domInteractive1023329852109232
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect28186883244
firstReactRender28236052940
getState83709718
initialActions3122339
loadScripts1179104214037812431303
setupStore1156912846
WebpackHomeuiStartup16091373223515516971871
load13671171171113114581576
domContentLoaded13661170171113114571576
domInteractive1093332952119192
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect30195073744
firstReactRender38314834046
getState8314516615
initialActions7121022321
loadScripts13441147168613114381557
setupStore105658930
Bundle size diffs [🚀 Bundle size reduced!]
  • background: 54 Bytes (0%)
  • ui: -56 Bytes (0%)
  • common: -127 Bytes (0%)

@FrederikBolding FrederikBolding marked this pull request as ready for review October 3, 2025 14:47
@FrederikBolding FrederikBolding requested review from a team as code owners October 3, 2025 14:47
});
} else {
optimizedBuffer = await sharp(filePath, {
const optimizedBuffer = await sharp(filePath, {
Copy link

Choose a reason for hiding this comment

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

Bug: Image Optimization Issues with Sharp

The code now uses sharp for all image optimizations, including GIFs, but applies toFormat() options like compressionLevel, effort, quality, and lossless universally. These options are not valid for all formats, particularly GIFs, which can cause runtime errors, suboptimal compression, or loss of animation quality.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems to have worked for optimizing spinner.gif 🤷‍♂️

@FrederikBolding FrederikBolding added this pull request to the merge queue Oct 3, 2025
github-merge-queue bot pushed a commit that referenced this pull request Oct 3, 2025
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

Seemingly `sharp` is as efficient at optimizing GIFs as `imagemin` and
doesn't have the same install-script problems on some systems that
`gifsicle` brings. This PR proposes to use `sharp` for optimizing all
images.

Needs a sanity check.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/36563?quickstart=1)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Replace `imagemin`/`gifsicle` with `sharp` for image optimization and
remove related dependencies, updating configs and LavaMoat policies
accordingly.
> 
> - **Development tooling**:
> - `development/optimize-media.mts`: Use `sharp` exclusively for all
image formats; remove `imagemin`/`imagemin-gifsicle` logic and imports.
> - **Dependencies**:
> - Remove `imagemin`, `imagemin-gifsicle`, and their `@types` from
`package.json`; prune related entries from `yarn.lock`.
>   - Update `.depcheckrc.yml` to drop `imagemin*` from ignored deps.
> - **Security/Policies**:
> - Update LavaMoat policies (`lavamoat/browserify/*/policy.json`,
`lavamoat/build-system/policy.json`) to adjust package mappings (e.g.,
`is-plain-obj` path) and remove allowlist for
`imagemin-gifsicle>gifsicle`.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
c6a9ae5. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: MetaMask Bot <[email protected]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template size-S team-core-platform Core Platform team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants