[0.83] fix(metro): vendor image dimension parsing (#1860) - #1871
Merged
Conversation
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 Pull Request resolved: #1860 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. Reviewed By: huntie Differential Revision: D116437966 Pulled By: javache fbshipit-source-id: 9f88b14668ae863b22a4aaf91b1298967c7f07c1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick #1860 to 0.83
Summary:
image-sizedependency with an in-tree parser for the image formats Metro supportsThis removes
image-sizeand itsqueuedependency without introducing a new third-party package. The parser is derived from the MIT-licensedimage-sizeformat support, with its notice retained inline and bounds/forward-progress checks added throughout.Refs #1762
Refs #1800
Pull Request resolved: #1860
Test Plan:
yarn flow checkyarn typecheck-tsyarn lintyarn buildnode node_modules/jest/bin/jest.js packages/metro/src/lib/__tests__/imageSize-test.js packages/metro/src/__tests__/Assets-test.js --runInBand --no-watchmanimage-sizecorpusChangelog: [Fix] Remove the image-size dependency and parse supported image dimensions within Metro.