Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(android): handle width and height as strings in ImageAsset options #10728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

thearnabsaha
Copy link

PR Checklist


What is the current behavior?

When ImageAsset.options.width and options.height are provided as strings (e.g., "300"), the Android implementation crashes. The method loadImageAsync expects numeric values for dimensions, but receives a stringified version, causing an exception and breaking image loading.


What is the new behavior?

  • Explicitly parses options.width and options.height using parseInt().
  • Prevents crashes when developers provide string values.
  • Defaults to Screen.mainScreen.widthPixels and heightPixels when parsing fails.
  • Adds resilience to the image loading logic and improves developer experience.

Fixes #10668


Additional Notes

  • This update resolves a breaking bug that affected multiple NativeScript users.
  • Validated across devices with both numeric and string values.
  • PR tested manually; guidance requested to add or locate proper unit tests for ImageAsset.

@CatchABus
Copy link
Contributor

CatchABus commented Apr 10, 2025

@thearnabsaha I suspect getRequestedImageSize takes care of this on iOS but fails on android since we don't use the method there at all. You can try adapting it from iOS and see if the problem still persists since there's a chance those casts might not be needed.

To be more precise, it'd be more desirable to have a common parse handling for both platforms.

@thearnabsaha thearnabsaha closed this by deleting the head repository Apr 15, 2025
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.