Skip to content

fix(metro): vendor image dimension parsing - #1860

Open
robhogan wants to merge 1 commit into
mainfrom
fix/vendor-image-size
Open

fix(metro): vendor image dimension parsing#1860
robhogan wants to merge 1 commit into
mainfrom
fix/vendor-image-size

Conversation

@robhogan

Copy link
Copy Markdown
Contributor

Summary

  • replace the image-size dependency with an in-tree parser for the image formats Metro supports
  • dispatch by the declared asset type rather than running unrelated format detectors
  • preserve CgBI PNG, SVG units/viewBox, TIFF endianness, WebP variants, and KTX1/KTX2 support
  • reuse the first asset buffer already read for hashing
  • reject truncated, mismatched, non-positive, and non-advancing malformed inputs

This removes image-size and its queue dependency without introducing a new third-party package. The parser is derived from the MIT-licensed image-size format support, with its notice retained inline and bounds/forward-progress checks added throughout.

Refs #1762
Refs #1800

Test plan

  • yarn flow check
  • yarn typecheck-ts
  • yarn lint
  • yarn build
  • node node_modules/jest/bin/jest.js packages/metro/src/lib/__tests__/imageSize-test.js packages/metro/src/__tests__/Assets-test.js --runInBand --no-watchman
  • full Jest run: 141 suites passed; the two Watchman integration suites failed because the local environment cannot chmod the shared Watchman state directory
  • checked all applicable fixtures from the upstream image-size corpus
  • exercised 100,000 randomized malformed buffers across all parsers

Changelog: [Fix] Remove the image-size dependency and parse supported image dimensions within Metro.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 16, 2026
@robhogan
robhogan force-pushed the fix/vendor-image-size branch from 9f96097 to dfcb2d4 Compare August 16, 2026 21:11
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant