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

iOS: border width and color renders incorrectly on iOS for particular values #21945

Closed
rroehrig opened this issue Oct 25, 2018 · 18 comments
Closed
Labels
Bug Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@rroehrig
Copy link

rroehrig commented Oct 25, 2018

Environment

  React Native Environment Info:
    System:
      OS: macOS Sierra 10.12.6
      CPU: x64 Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz
      Memory: 38.27 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.11.3 - /usr/local/opt/node@8/bin/node
      Yarn: yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 31.83s. - /usr/local/bin/yarn
      npm: 5.6.0 - /usr/local/opt/node@8/bin/npm
      Watchman: 4.7.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.2, macOS 10.13, tvOS 11.2, watchOS 4.2
      Android SDK:
        Build Tools: 23.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.3
        API Levels: 23, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.1 AI-173.4907809
      Xcode: 9.2/9C40b - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.0-alpha.8af6728 => 16.6.0-alpha.8af6728 
      react-native: 0.57.3 => 0.57.3 
    npmGlobalPackages:
      create-react-native-app: 1.0.0
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7

Description

I have a triangle build with View and styles only. It renders incorrectly depending on the width/height values on iOS. The problem occurred after upgrading to react-native 0.57.3 (from 0.55.x).

Actual:
bildschirmfoto 2018-10-25 um 14 13 08

Expected:
bildschirmfoto 2018-10-25 um 14 11 23

Reproducible Demo

The following snippet is not working (tested with iPhone 6 Plus and iPhone X):

<View style={{
                width: 0,
                height: 0,
                backgroundColor: 'transparent',
                borderStyle: 'solid',
                borderTopWidth: 0,
                borderRightWidth: 82.4,
                borderBottomWidth: 82.4,
                borderLeftWidth: 0,
                borderTopColor: 'transparent',
                borderRightColor: 'red',
                borderBottomColor: 'transparent',
                borderLeftColor: 'transparent',
            }}
            />

The following snippet is working:

<View style={{
                width: 0,
                height: 0,
                backgroundColor: 'transparent',
                borderStyle: 'solid',
                borderTopWidth: 0,
                borderRightWidth: 82.5,
                borderBottomWidth: 82.5,
                borderLeftWidth: 0,
                borderTopColor: 'transparent',
                borderRightColor: 'red',
                borderBottomColor: 'transparent',
                borderLeftColor: 'transparent',
            }}
            />

It's just an example, there are much more values showing the problem!

@react-native-bot react-native-bot added the Platform: iOS iOS applications. label Oct 25, 2018
@mezod
Copy link

mezod commented Nov 1, 2018

Very same issue occurring here. Upgrading from 0.55 to 0.57.4.

screen shot 2018-11-01 at 20 10 03

         borderTopWidth: 40,
         borderRightWidth: 0,
         borderBottomWidth: 0,
         borderLeftWidth: 60,
         borderTopColor: 'transparent',
         borderRightColor: 'transparent',
         borderBottomColor: 'transparent',
         borderLeftColor: this.props.color,

@ddesvillechabrol
Copy link

Hello,

I had the same issue with react-native 0.57.4 and I deleted this commit dba2235 to retrieve my triangles.

Dimitri

@mezod
Copy link

mezod commented Nov 8, 2018

Hey Dimitri! Thanks! By deleting the commit you mean you forked react-native or just changed it in your node_modules while you wait for an upgrade? (i'm not fond of any of both solutions that's why I'm asking :P)

@ddesvillechabrol
Copy link

Hey ! Yeah I forked react-native repo and I added a commit to undo changes 😄

@michaelknoch
Copy link

I rewrote my triangles to use transforms today. Maybe the comment "// Asymmetrical edgeInsets cause strange artifacting on iOS 10 and earlier." makes sense

@mezod
Copy link

mezod commented Nov 15, 2018

@michaelknoch care to share an example of how you implement triangles now? :P

@angelos3lex
Copy link

Any workaround on this guys?

@FadiAboMsalam
Copy link

any solution for this guys ?

t-benze referenced this issue Jan 2, 2019
Summary:
This PR fixes an obscure rendering bug on iOS for borders with asymmetric radii. It appears to be a problem with the custom drawing that React Native performs when it cannot use native UIKit/CoreAnimation border drawing.
Pull Request resolved: #21208

Differential Revision: D10130120

Pulled By: hramos

fbshipit-source-id: d9fbc5c622c060db15658d038a068216b47bb26d
@jamesreggio
Copy link
Contributor

Ah, yikes. @t-benze is right: the regression occurred in a fix I made for another border issue.

Here's the original issue: #11897
Here's my PR with justification: #21208

There was another suggested fix in this PR: #19451

I would suggest that you try incorporating the patch from #19451 and see if it regresses the border-triangle functionality. If it doesn't, open a PR to revert my change (dba2235) and include the other fix from #19451.

Sorry about this!

@csath
Copy link

csath commented Jan 21, 2019

#19451 patch didn't work for me. I reverted the (dba2235) commit and now it works as previously.

@FadiAboMsalam
Copy link

is this fixed in react-native 0.58.3 ?
any suggestion how to fix ?

@hramos hramos removed the Bug Report label Feb 6, 2019
facebook-github-bot pushed a commit that referenced this issue Feb 13, 2019
Summary:
Fixes #22824 #21945 , the bug comes from #21208 , it was to fix #11897. Now Let's constrain edge adjust only when view has corners.

[iOS] [Fixed] - Fix triangle views on iOS
Pull Request resolved: #23402

Differential Revision: D14059192

Pulled By: hramos

fbshipit-source-id: be613bf056d3cc484f281f7ea3d08f251971700a
@rpavlovs
Copy link

This changes breaks semi-circles as well.

Before:
image

After:
image

Manually patching to revert the change fixes the issue.
#23402 Didn't help since it only disables if for hasCornerRadii which we need to set.

What's the best course of actions to fix this?

@johman10
Copy link

johman10 commented Mar 18, 2019

I have found a fix for the triangle issue. Adding a border radius of any value bigger than 0 seems to fix the issue for now without reverting any commit.

Complete styles that work for me:

borderTopWidth: 0,
borderRightWidth: 50,
borderBottomWidth: 50,
borderLeftWidth: 0,
borderTopColor: 'transparent',
borderRightColor: 'red',
borderBottomColor: 'transparent',
borderLeftColor: 'transparent',
width: 0,
height: 0,
backgroundColor: 'transparent',
borderStyle: 'solid',
borderRadius: 0.000001,
without borderRadius with borderRadius
image image

Hope this helps some of you!

grabbou pushed a commit that referenced this issue Apr 8, 2019
Summary:
Fixes #22824 #21945 , the bug comes from #21208 , it was to fix #11897. Now Let's constrain edge adjust only when view has corners.

[iOS] [Fixed] - Fix triangle views on iOS
Pull Request resolved: #23402

Differential Revision: D14059192

Pulled By: hramos

fbshipit-source-id: be613bf056d3cc484f281f7ea3d08f251971700a
@mezod
Copy link

mezod commented May 9, 2019

After having fixed the issue using borderRadius: 0.000001, the error started appearing again randomly (some triangles would appear cut while some others not) setting a bigger borderRadius made the trick, so borderRadius: 1, works better

@stale
Copy link

stale bot commented Aug 7, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 7, 2019
@mezod
Copy link

mezod commented Aug 8, 2019

This issue still exists. Using a borderRadius: 0.000001 doesn't work in a few cases still and using borderRadius: 1 works for 95% of the cases but the triangles still appear cut in some older devices like iPad Mini.

On the other hand, increasing borderRadius removes a pixel from the opposite edge as shown here:

It's barely perceptible and not a big deal, but perceptible enough for people to notice.

Ultimately, using borderRadius feels hacky.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 8, 2019
@stale
Copy link

stale bot commented Nov 6, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 6, 2019
@stale
Copy link

stale bot commented Nov 13, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Nov 13, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests