Skip to content

Conversation

@ira-po
Copy link

@ira-po ira-po commented Oct 30, 2025

Summary

This PR fixes issue #6289, where setting width or height as a string in ImageAssetOptions caused an error on Android (bitmap size exceeds 32 bits).

Problem

When width or height were provided as strings (e.g., "300" instead of 300), the Android code failed to process them correctly, leading to a crash, especially on older API levels (e.g., API 22).

How to test

Create an ImageAsset instance with width/height as strings and call getImageAsync.
Before this fix, Android API 22 would crash.
After this fix, the image loads successfully without errors.

Solution

Before passing the options to the native method, this PR checks if width or height are strings and converts them to numbers using parseInt.

if (typeof this.options.width === "string") {
  this.options.width = parseInt(this.options.width, 10);
}
if (typeof this.options.height === "string") {
  this.options.height = parseInt(this.options.height, 10);
}

@cla-bot
Copy link

cla-bot bot commented Oct 30, 2025

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Ira Pochaievets.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@ira-po ira-po force-pushed the fix-imageassetoptions-typecheck branch from 04aba33 to c42d2c2 Compare October 30, 2025 15:45
@NathanWalker
Copy link
Contributor

Hey! Thanks so much for opening a pull request!

A prior PR was opened to solve this issue here: #10862 which will be merging.

Thanks again, and we look forward to seeing more PRs from you in the future! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants