Skip to content
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

Crash: RadialGradient using radius of 0 #47

Closed
Czino opened this issue Apr 28, 2022 · 3 comments
Closed

Crash: RadialGradient using radius of 0 #47

Czino opened this issue Apr 28, 2022 · 3 comments

Comments

@Czino
Copy link

Czino commented Apr 28, 2022

I found that the radialGradient function crashes when passed with a shadowRadius of 0

function radialGradient(id, top, left, radius, shadowRadius) {
  return (<RadialGradient id={id} cx={left ? shadowRadius : 0} cy={top ? shadowRadius : 0} r={shadowRadius} ...
}

Error

 java.lang.IllegalArgumentException: radius must be > 0
        at android.graphics.RadialGradient.<init>(RadialGradient.java:104)
        at android.graphics.RadialGradient.<init>(RadialGradient.java:67)
        at com.horcrux.svg.Brush.setupPaint(Brush.java:213)

This is the component that makes it crash

<Shadow distance={0} radius={0} startColor="#E43B5F" finalColor="#E43B5F" />

I cleaned up my code to not having to encounter this case but I am still raising this issue because I think the package could handle it more gracefully, even if it's a warning or error log and fallback to sensible values.

@SrBrahma
Copy link
Owner

SrBrahma commented Apr 28, 2022

Many thanks for the report. I had some crashes when the distance is 0, maybe this is what caused them (the shadowRadius = radius + distance). I will investigate this asap.

I had planned to fix this on 7.0.0, but I will release a hotfix for it as a patch to v6.

SrBrahma added a commit that referenced this issue Apr 28, 2022
SrBrahma added a commit that referenced this issue Apr 28, 2022
@SrBrahma
Copy link
Owner

SrBrahma commented May 1, 2022

Hi! I had the time to test the patch today.

Just released it in 6.0.5 via ce32eea.

I would appreciate if you also test it and give me your feedback about it!

Thanks!

@SrBrahma SrBrahma closed this as completed May 1, 2022
@Czino
Copy link
Author

Czino commented May 3, 2022

Just tested it, setting distance and radius explicitly to 0 doesn't result in a crash anymore

@SrBrahma SrBrahma mentioned this issue May 3, 2022
2 tasks
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

No branches or pull requests

2 participants