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

fix: border rendering problem in Android #36129

Conversation

BeeMargarida
Copy link
Contributor

@BeeMargarida BeeMargarida commented Feb 10, 2023

Summary

Fixes #36036

The problem was in ReactViewBackgroundDrawable.java that was not accounting for adjacent borders that add width set to 0.

Changelog

[Android] [Fixed] - Fix border rendering issue when bottom borders has no width

Test Plan

Previously Now with the fix
image image

@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 10, 2023
@react-native-bot react-native-bot added Bug Platform: Android Android applications. labels Feb 10, 2023
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,479,906 +140
android hermes armeabi-v7a 7,800,769 +145
android hermes x86 8,955,600 +138
android hermes x86_64 8,813,441 +150
android jsc arm64-v8a 9,117,152 +186
android jsc armeabi-v7a 8,313,222 +184
android jsc x86 9,168,554 +185
android jsc x86_64 9,427,379 +176

Base commit: 96df8c0
Branch: main

@facebook-github-bot
Copy link
Contributor

@javache has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@cipolleschi
Copy link
Contributor

/rebase

@@ -963,7 +965,9 @@ private void updatePath() {
}

mInnerBottomRightCorner.x = mInnerClipTempRectForBorderRadius.right;
mInnerBottomRightCorner.y = mInnerClipTempRectForBorderRadius.bottom * -2;
mInnerBottomRightCorner.y = borderWidth.bottom != 0
Copy link
Member

@javache javache Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why don't need this logic for mInnerTopLeftCorner and mInnerTopRightCorner?

Copy link
Contributor Author

@BeeMargarida BeeMargarida Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can be added (my bad, I kinda had tunnel vision). In the cases where this bug happened it won't cause any difference though, because mInnerClipTempRectForBorderRadius.top was always 0. Do you want me to make a commit adding the same logic to mInnerTopLeftCorner and mInnerTopRightCorner?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't make a difference, we shouldn't add it. So you're saying we don't need similar logic for the top corners?

Copy link
Contributor Author

@BeeMargarida BeeMargarida Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not totally sure. From what I saw from the code, mInnerClipTempRectForBorderRadius is set based on the getBounds of the drawable. In cases where the bounds don't change, top will always be 0. Is there any possibility of the bounds changing in this case?

Update: ah, there is if we change the size of drawable...I'll test it (nvm, not the case, from what I can tell top will always remain 0)

@javache
Copy link
Member

javache commented Feb 16, 2023

Looks like this logic was changed not too long ago in #34362. It seems there was no test-case added at that time, can you verify this doesn't regress it?

@BeeMargarida
Copy link
Contributor Author

Looks like this logic was changed not too long ago in #34362. It seems there was no test-case added at that time, can you verify this doesn't regress it?

Seems like there is no regression 👍
image

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Feb 16, 2023
@facebook-github-bot
Copy link
Contributor

@javache merged this pull request in 1d51032.

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 2023
Summary:
Fixes facebook#36036

The problem was in `ReactViewBackgroundDrawable.java` that was not accounting for adjacent borders that add width set to 0.

## Changelog

[Android] [Fixed] - Fix border rendering issue when bottom borders has no width

Pull Request resolved: facebook#36129

Test Plan:
| Previously | Now with the fix  |
| --------------- | --------------- |
| <img width="417" alt="image" src="https://user-images.githubusercontent.com/25725586/218149384-00e2145c-3c84-4590-87be-3258574489e5.png"> | <img width="414" alt="image" src="https://user-images.githubusercontent.com/25725586/218148215-a8d37158-0feb-47ae-874b-cba2f422d792.png">  |

Reviewed By: cipolleschi

Differential Revision: D43303228

Pulled By: javache

fbshipit-source-id: cf9d30fe12a5740d9ee8974a66904fd0850e7606
@zbranevichfinstek
Copy link

zbranevichfinstek commented Jun 8, 2023

@javache Please add this to 0.71

@javache
Copy link
Member

javache commented Jun 13, 2023

@zbranevichfinstek: please raise this in the 0.71 release thread - https://github.com/reactwg/react-native-releases/discussions

@lanphammm
Copy link

lanphammm commented Apr 29, 2024

I don't want to upgrade the react native version, so is there any way to fix this issue?
I have tried editing file ReactViewBackgroundDrawable.java inside node_modules but it's failed.

Dependencies: {
"react": "18.2.0",
"react-native": "0.71.3"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[^0.71.0] - borderLeftColor and borderRightColor is not rendered properly
8 participants