Skip to content

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

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

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
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 2 times, most recently from 7995cd5 to 5942579 Compare May 23, 2026 16:28
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request May 23, 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 5942579 to 4ffe356 Compare June 1, 2026 16:10
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request Jun 1, 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
…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 4ffe356 to 27720cc Compare June 2, 2026 01:16
Abbondanzo added a commit to Abbondanzo/react-native that referenced this pull request Jun 3, 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
@meta-codesync meta-codesync Bot closed this in aea8785 Jun 3, 2026
@facebook-github-tools facebook-github-tools Bot added the Merged This PR has been merged. label Jun 3, 2026
@meta-codesync
Copy link
Copy Markdown

meta-codesync Bot commented Jun 3, 2026

This pull request has been merged in aea8785.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @Abbondanzo in aea8785

When will my fix make it into a release? | How to file a pick request?

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 Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants