[Android] Image control crashes on Android when image width exceeds height #33045
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.
Issue Details:
The user reads a local image, converts it into a byte array, creates a temporary file from it, and assigns the file’s path to the Image control’s Source property, but an exception occurs during this process.
Root Cause:
PlatformInterop.LoadImageFromFile(imageView, file, callback) fails to load the temporary file, which causes an exception to be thrown.
Description of Change:
The fix introduces a constrainSize parameter that, when enabled, applies override to the Glide RequestBuilder, forcing image decoding at original dimensions rather than scaled dimensions. This constraint reduces memory usage from hundreds of megabytes to manageable levels while preserving visual quality through ImageView's built-in scaling capabilities. The fix is automatically applied to all image loading methods including and ensuring consistent behavior across different image sources without breaking existing functionality or requiring API changes.
Tested the behavior in the following platforms.
Reference:
N/A
Issues Fixed:
Fixes #32869
Screenshots