Skip to content

Support resource drawable URIs in Image.getSize() on Android (#56944)#56944

Open
Abbondanzo wants to merge 1 commit into
facebook:mainfrom
Abbondanzo:export-D106045223
Open

Support resource drawable URIs in Image.getSize() on Android (#56944)#56944
Abbondanzo wants to merge 1 commit into
facebook:mainfrom
Abbondanzo:export-D106045223

Conversation

@Abbondanzo
Copy link
Copy Markdown
Contributor

@Abbondanzo Abbondanzo commented May 22, 2026

Summary:

Image.getSize() and Image.getSizeWithHeaders() always failed for Android drawable resource URIs (e.g. "res_ic_home_filled_20") because Fresco's fetchEncodedImage pipeline does not handle res:// URIs — it throws IllegalArgumentException("Unsupported uri scheme for encoded image fetch!").

This adds a fast path in ImageLoaderModule that detects resource URIs via ImageSource.isResource and resolves their intrinsic dimensions through Android's Drawable API (ResourceDrawableIdHelper.getResourceDrawable() -> Drawable.getIntrinsicWidth/Height()). This works for all drawable types including VectorDrawables, which are compiled XML and cannot be decoded by Fresco's raster-oriented pipeline.

For non-resource URIs (network, file, content), the existing Fresco fetchEncodedImage path is unchanged.

Changelog:
[Android][Fixed] - Fix Image.getSize() failing for local drawable resource URIs including VectorDrawables

Differential Revision: D106045223

@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 May 22, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented May 22, 2026

@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D106045223.

@meta-codesync meta-codesync Bot changed the title Support resource drawable URIs in Image.getSize() on Android Support resource drawable URIs in Image.getSize() on Android (#56944) May 22, 2026
@Abbondanzo Abbondanzo force-pushed the export-D106045223 branch from 0db2032 to 56b8322 Compare May 22, 2026 17:35
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request May 22, 2026
…ook#56944)

Summary:

`Image.getSize()` and `Image.getSizeWithHeaders()` always failed for Android drawable resource URIs (e.g. `"res_ic_home_filled_20"`) because Fresco's `fetchEncodedImage` pipeline does not handle `res://` URIs — it throws `IllegalArgumentException("Unsupported uri scheme for encoded image fetch!")`.

This adds a fast path in `ImageLoaderModule` that detects resource URIs via `ImageSource.isResource` and resolves their intrinsic dimensions through Android's `Drawable` API (`ResourceDrawableIdHelper.getResourceDrawable()` -> `Drawable.getIntrinsicWidth/Height()`). This works for all drawable types including VectorDrawables, which are compiled XML and cannot be decoded by Fresco's raster-oriented pipeline.

For non-resource URIs (network, file, content), the existing Fresco `fetchEncodedImage` path is unchanged.

Changelog:
[Android][Fixed] - Fix `Image.getSize()` failing for local drawable resource URIs including VectorDrawables

Differential Revision: D106045223
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request May 22, 2026
…ook#56944)

Summary:

`Image.getSize()` and `Image.getSizeWithHeaders()` always failed for Android drawable resource URIs (e.g. `"res_ic_home_filled_20"`) because Fresco's `fetchEncodedImage` pipeline does not handle `res://` URIs — it throws `IllegalArgumentException("Unsupported uri scheme for encoded image fetch!")`.

This adds a fast path in `ImageLoaderModule` that detects resource URIs via `ImageSource.isResource` and resolves their intrinsic dimensions through Android's `Drawable` API (`ResourceDrawableIdHelper.getResourceDrawable()` -> `Drawable.getIntrinsicWidth/Height()`). This works for all drawable types including VectorDrawables, which are compiled XML and cannot be decoded by Fresco's raster-oriented pipeline.

For non-resource URIs (network, file, content), the existing Fresco `fetchEncodedImage` path is unchanged.

Changelog:
[Android][Fixed] - Fix `Image.getSize()` failing for local drawable resource URIs including VectorDrawables

Differential Revision: D106045223
@Abbondanzo Abbondanzo force-pushed the export-D106045223 branch from 56b8322 to 2a46c33 Compare May 22, 2026 18:14
…ook#56944)

Summary:

`Image.getSize()` and `Image.getSizeWithHeaders()` always failed for Android drawable resource URIs (e.g. `"res_ic_home_filled_20"`) because Fresco's `fetchEncodedImage` pipeline does not handle `res://` URIs — it throws `IllegalArgumentException("Unsupported uri scheme for encoded image fetch!")`.

This adds a fast path in `ImageLoaderModule` that detects resource URIs via `ImageSource.isResource` and resolves their intrinsic dimensions through Android's `Drawable` API (`ResourceDrawableIdHelper.getResourceDrawable()` -> `Drawable.getIntrinsicWidth/Height()`). This works for all drawable types including VectorDrawables, which are compiled XML and cannot be decoded by Fresco's raster-oriented pipeline.

For non-resource URIs (network, file, content), the existing Fresco `fetchEncodedImage` path is unchanged.

Changelog:
[Android][Fixed] - Fix `Image.getSize()` failing for local drawable resource URIs including VectorDrawables

Differential Revision: D106045223
@Abbondanzo Abbondanzo force-pushed the export-D106045223 branch from 2a46c33 to 7995cd5 Compare May 22, 2026 18:15
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. fb-exported meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant