Support resource drawable URIs in Image.getSize() on Android (#56944)#56944
Open
Abbondanzo wants to merge 1 commit into
Open
Support resource drawable URIs in Image.getSize() on Android (#56944)#56944Abbondanzo wants to merge 1 commit into
Image.getSize() on Android (#56944)#56944Abbondanzo wants to merge 1 commit into
Conversation
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D106045223. |
Image.getSize() on AndroidImage.getSize() on Android (#56944)
0db2032 to
56b8322
Compare
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
56b8322 to
2a46c33
Compare
…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
2a46c33 to
7995cd5
Compare
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.
Summary:
Image.getSize()andImage.getSizeWithHeaders()always failed for Android drawable resource URIs (e.g."res_ic_home_filled_20") because Fresco'sfetchEncodedImagepipeline does not handleres://URIs — it throwsIllegalArgumentException("Unsupported uri scheme for encoded image fetch!").This adds a fast path in
ImageLoaderModulethat detects resource URIs viaImageSource.isResourceand resolves their intrinsic dimensions through Android'sDrawableAPI (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
fetchEncodedImagepath is unchanged.Changelog:
[Android][Fixed] - Fix
Image.getSize()failing for local drawable resource URIs including VectorDrawablesDifferential Revision: D106045223