-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
[Android] Fix overflow hidden with transform rotate on a View with borderRadius #28881
Conversation
ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java
Outdated
Show resolved
Hide resolved
We found a crash on some android 9 and android 10 devices(xiaomi ,vivo). #28881 Fixes this issue The crash is fixed when we use |
This comment has been minimized.
This comment has been minimized.
Base commit: 84a81da |
Base commit: 84a81da |
Is this a fix for this issue? Because on #18208, issue still happens on my device. I took those screenshots today. Version:react: 16.13.1 => 16.13.1 Expected:Result: |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code analysis results:
google-java-format
found some issues. See https://github.com/google/google-java-format
ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java
Outdated
Show resolved
Hide resolved
You could try fixing this by using prop https://reactnative.dev/docs/view#rendertohardwaretextureandroid
My pr would just enable hardware accelleration on that view after applying the border radius, but you could solve this issue by enabling hardware accelleration on the view in Javascript for Android API N till P react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java Lines 267 to 270 in e6658a2
the prop allows you to call react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java Lines 120 to 122 in 1465c8f
|
Thanks a lot for this fix! It solves an important issue for us. We are running app builds with this fix since almost a year now. This requires us to build patched versions of React Native ourselves, which is quite a hassle. Is there any chance this PR will get merged? |
Hello, I have an unrelated question, doesn't your app target under N api? , the last comment says it works from N onwards. |
Our app supports Android 21+. This fix is for Android 24-28, which is 5% of our Android users. |
Thank you so much for responding, what I'm exactly trying to know is what do you do for 21 to 23 then? Conditionally remove the border I guess? |
As far as I know, this bug doesn't occur on these versions |
@fabOnReact Why this PR has not been merged? This issue still seems to be open but yet not resolved. |
Summary
This issue fixes #18266 fixes #22215 fixes #19637 fixes #29312
Related #29265 #18208
The bug affects Android Devices running Sdk from 24 (Nougat) to 28 (Pie). The method clipPath does not correctly crop Views with overflow:hidden and LAYER_TYPE_NONE if the parent View has rounded border and transform rotate. The View is cropped without considering the transform rotate effect. Additional information are available on the discussion #18266. Ramanpreet Nara (RSNara) contributed to solve this issue implementing rounded borders functionality in 4994d6a.
Changelog
[Android] [Fixed] - Fix overflow hidden with transform rotate on a View with borderRadius
Test Plan
CLICK TO OPEN TESTS RESULTS
The solution uses
setLayerType
to change the layer toLAYER_TYPE_HARDWARE
.setLayerType
specifies the type of layer backing this view.The change is applied only to Views with overflow hidden running on sdk 24-28.
The below screenshots are from
RNTester
transformation examples.The screenshot on the left displays how the
clipPath
method crops incorrectly using aPath
shape without thetransform: { rotate: "30deg" }
effect. TheView
is cropped as if no rotation was applied. The screenshot on the right displays the result after implementing the patch.The below tests performed with
RNTester
Animated examples do not identify any issue when running animations. Gif image quality was reduced to respect github upload limits. Thanks a lot. 😃 Fabrizio Bertoglio