Skip to content

Conversation

@joevilches
Copy link
Contributor

Summary:
I noticed that when inset shadows have a smaller blur radius than spread its wrong and there is a gap between the edge of the box and the shadow. I think the outer rect is just defined incorrectly and we should be adjusting the paddingBox as opposed to the innerRect. The innerRect is just the padding box insetted by the spread, so that is why we see gaps if blur < spread

Changelog: [Android][Fixed] - Fix inset boxShadow when blur < spread

Differential Revision: D69688508

Summary:
An internal crash report notified us that we were getting an `IllegalArgumentException` in Android's `BlurMaskFilter` used in Box Shadows. The only requirement for the arguments there are that the blur radius is positive. We ensure that, but pass to `sigmaToRadius` afterwards, which does NOT ensure that. This updates that conversion so that

* We will never return negative numbers, regardless of what `PixelUtil.toDIPFromPixel` is doing
* Small enough numbers ( < 0.5) will just go through as 0.0, which is what Android does in https://cs.android.com/android/platform/superproject/main/+/main:frameworks/base/libs/hwui/utils/Blur.cpp;l=34
* Ensure shadows check that we have a POSITIVE blur radius AFTER conversion. sigmaToRadius can still return 0 which with also throw, so gotta make sure we change our checks. Filter blurs and dropShadow should be ok, renderEffect does not mention anything about being > 0 in the docs.

Changelog: [Android] [Fixed] - Fix issue where boxShadow crashes with small blur radius

Facebook
Post alerting us of this: https://fb.workplace.com/groups/rn.panelapps/permalink/1136446121310146/

Differential Revision: D69683031
Summary:
I noticed that when inset shadows have a smaller blur radius than spread its wrong and there is a gap between the edge of the box and the shadow. I think the outer rect is just defined incorrectly and we should be adjusting the paddingBox as opposed to the innerRect. The innerRect is just the padding box insetted by the spread, so that is why we see gaps if blur < spread

Changelog: [Android][Fixed] - Fix inset boxShadow when blur < spread

Differential Revision: D69688508
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 15, 2025
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69688508

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in a3b29e1.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @joevilches in a3b29e1

When will my fix make it into a release? | How to file a pick request?

gabrieldonadel pushed a commit to gabrieldonadel/react-native that referenced this pull request Aug 12, 2025
Summary:
Pull Request resolved: facebook#49448

I noticed that when inset shadows have a smaller blur radius than spread its wrong and there is a gap between the edge of the box and the shadow. I think the outer rect is just defined incorrectly and we should be adjusting the paddingBox as opposed to the innerRect. The innerRect is just the padding box insetted by the spread, so that is why we see gaps if blur < spread

Changelog: [Android][Fixed] - Fix inset boxShadow when blur < spread

Reviewed By: jorge-cab

Differential Revision: D69688508

fbshipit-source-id: 911258edd9a8403c70992800c3e1a5ea044e1f3b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants