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

ClipPath rendering white background on iOS #1131

Closed
Relax594 opened this issue Oct 1, 2019 · 11 comments · Fixed by BlueWallet/BlueWallet#847 or mdfkbtc/veles-mobile-wallet-mdfkbtc#3 · May be fixed by GraoMelo/hathor-wallet-mobile#1

Comments

@Relax594
Copy link

Relax594 commented Oct 1, 2019

Bug

Svg is displayed with a white background and because of that not visible on iOS. Android is totally fine somehow. This is happening after upgrading from 9.9.0 to 9.10.0. Every version before 9.9.0 worked. We haven't tested the versions between 9.9.0 and 9.10.0.

This is how it should be:
Screenshot_1569940040

And this is how it is after upgrading:
Screenshot_1569940023

Environment info

React native info output:

 React Native Environment Info:
    System:
      OS: Windows 8.1
      CPU: (8) x64 Intel(R) Xeon(R) CPU           E5630  @ 2.53GHz
      Memory: 41.90 GB / 48.00 GB
    Binaries:
      Yarn: 1.17.3 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5791312

Library version: 9.10.0

Steps To Reproduce

  1. Just use the Svg on a button or whatever with 9.10.0
  2. Use the same Svg on the same button with every version below 9.9.0

Describe what you expected to happen:

  1. I wanted this
    Screenshot_1569940040

  2. but got this
    Screenshot_1569940023

Reproducible sample code

<Svg width={32} height={32}>
        <G transform="matrix(.9382 0 0 .93123 2 .926)" fill="#fff">
            <ClipPath id="prefix__a">
                <Path d="M27.11 12.782l-4.266-4.219L23.4 8H18V2h5.367l-.523-.529L24.331 0H0v32h32V7.837z" fill="#FFF" />
            </ClipPath>
            <G clipPath="url(#prefix__a)">
                <Path d="M30 28H0V4h30zM2 26h26V8.445L17.949 17.88c-.936.823-1.866 1.206-2.925 1.206h-.019c-1.079 0-2.026-.39-2.979-1.227l-.024-.022L2 8.445zm11.358-9.633c.577.504 1.07.719 1.647.719h.019c.556 0 1.033-.209 1.593-.698L27.683 6H2.317z" />
            </G>
            <Path d="M27.094.08l4.882 4.937-4.882 4.936-1.422-1.406L28.191 6H20V4h8.158l-2.486-2.513z" />
        </G>
    </Svg>
@msand
Copy link
Collaborator

msand commented Oct 3, 2019

Try wrapping the ClipPath inside a Defs element:

export default class App extends React.Component {
 render() {
   return (
     <View style={styles.container}>
       <Svg width={32} height={32}>
         <Defs>
           <ClipPath id="prefix__a">
             <Path
               d="M27.11 12.782l-4.266-4.219L23.4 8H18V2h5.367l-.523-.529L24.331 0H0v32h32V7.837z"
               fill="#FFF"
             />
           </ClipPath>
         </Defs>
         <G transform="matrix(.9382 0 0 .93123 2 .926)" fill="#fff">
           <G clipPath="url(#prefix__a)">
             <Path d="M30 28H0V4h30zM2 26h26V8.445L17.949 17.88c-.936.823-1.866 1.206-2.925 1.206h-.019c-1.079 0-2.026-.39-2.979-1.227l-.024-.022L2 8.445zm11.358-9.633c.577.504 1.07.719 1.647.719h.019c.556 0 1.033-.209 1.593-.698L27.683 6H2.317z" />
           </G>
           <Path d="M27.094.08l4.882 4.937-4.882 4.936-1.422-1.406L28.191 6H20V4h8.158l-2.486-2.513z" />
         </G>
       </Svg>
     </View>
   );
 }
}

const styles = StyleSheet.create({
 container: {
   backgroundColor: 'black',
   justifyContent: 'center',
   alignItems: 'center',
   flex: 1,
 },
});

@Relax594
Copy link
Author

Relax594 commented Oct 7, 2019

That worked, thank you! In 9.11.1 this workaround is still needed.

msand added a commit that referenced this issue Oct 7, 2019
@msand
Copy link
Collaborator

msand commented Oct 7, 2019

I have a fix in the develop branch, could you test it out?
yarn add react-native-svg@react-native-community/react-native-svg#2534537

@Relax594
Copy link
Author

Relax594 commented Oct 7, 2019

Will give it a try tomorrow, thanks!

@Relax594
Copy link
Author

Relax594 commented Oct 8, 2019

@msand seems to be fine! Thanks for the quick fix!

@Relax594 Relax594 closed this as completed Oct 8, 2019
msand pushed a commit that referenced this issue Oct 19, 2019
# [9.12.0](v9.11.1...v9.12.0) (2019-10-19)

### Bug Fixes

* handle setting transform attribute on clipPath, fixes [#1152](#1152) ([73b21d1](73b21d1))
* improve handling of transform attribute on clipPath, fixes [#1152](#1152) ([3aa126e](3aa126e))
* **ios:** backwards compatible RCTImageLoader.h handling fixes [#1141](#1141) ([3c22c97](3c22c97))
* **ios:** clipPath rendering, fixes [#1131](#1131) ([2534537](2534537))
* **ios:** deprecation of RCTImageLoader fixes [#1141](#1141) ([5452144](5452144))
* **ios:** fix changes in color/currentColor/tintColor, fixes [#1151](#1151) ([0c7e94d](0c7e94d))
* **ios:** image viewBox opposite handling of y alignment, fixes [#1138](#1138) ([c69e9e2](c69e9e2))
* **js:** allow setting stopColor/Opacity/Offset using styles, fix [#1153](#1153) ([5984e06](5984e06))
* getPointAtLength signature ([2c57af2](2c57af2))
* getScreenCTM calculation ([5c5072d](5c5072d))
* improve native method spec conformance ([c63f9e2](c63f9e2))
* improve types for getBBox ([cecde7d](cecde7d))
* prepare script ([9a3dc4e](9a3dc4e))
* **ios:** memory leak in tspan, fixes [#1073](#1073) ([974f3a8](974f3a8))
* fix native methods spec conformance ([ecedb21](ecedb21))
* Make native methods synchronous ([8ce7611](8ce7611))
* refine types for matrix helpers ([409af91](409af91))
* refine types for matrix helpers ([7a3f867](7a3f867))
* **android:** defineMarker/getDefinedMarker storage ([e6eda84](e6eda84))
* **android:** native method scaling and getScreenCTM offset ([f3e0b19](f3e0b19))
* native method signatures web compatibility / spec conformance ([8687a3d](8687a3d))
* **ios:** optimize extractPathData, clear PathMeasure when no textPath ([df69c26](df69c26))

### Features

* **flow:** add flowgen to generate flow types from typescript, [#1125](#1125) ([fcd66fb](fcd66fb))
* implement getBBox, getCTM, getScreenCTM ([f13d54a](f13d54a))
* implement isPointInStroke ([2ba64df](2ba64df))
* initial implementation of isPointInFill ([203e53b](203e53b))
* support using native methods using promises instead of callbacks ([c28499b](c28499b))
* **android:** implement getTotalLength and getPointAtLength ([cd667d0](cd667d0))
* **ios:** implement getTotalLength and getPointAtLength ([78c4f20](78c4f20))
@msand
Copy link
Collaborator

msand commented Oct 19, 2019

🎉 This issue has been resolved in version 9.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@msand msand added the released label Oct 19, 2019
@harshitaahuja
Copy link

Still facing this issue on latest version 9.13.3 when using "react-native-svg-transformer": "^0.13.0",

@msand
Copy link
Collaborator

msand commented Nov 13, 2019

@harshitaahuja Can you provide a reproduction? And perhaps open a new issue, as this one is closed / resolved already.

@harshitaahuja
Copy link

harshitaahuja commented Nov 13, 2019

@msand Below is the svg file I am using

<svg xmlns="http://www.w3.org/2000/svg" id="copyright" width="13.563" height="13.563" viewBox="0 0 13.563 13.563">
    <defs>
        <style>
            .cls-1{fill:#fff}
        </style>
    </defs>
    <path id="Path_701" d="M6.781 13.563a6.781 6.781 0 1 1 6.781-6.781 6.789 6.789 0 0 1-6.781 6.781zm0-12.715a5.934 5.934 0 1 0 5.934 5.934A5.94 5.94 0 0 0 6.781.848z" class="cls-1" data-name="Path 701"/>
    <path id="Path_702" d="M114.214 117.6a3.391 3.391 0 1 1 2.423-5.763l-.606.593a2.543 2.543 0 1 0 0 3.559l.605.594a3.364 3.364 0 0 1-2.422 1.018z" class="cls-1" data-name="Path 702" transform="translate(-107.432 -107.432)"/>
</svg>

Usage
<Copyright width={13} height={13} fill={'#a5a'} />

Its working fine on android but showing white background on iOS.

@msand
Copy link
Collaborator

msand commented Nov 15, 2019

Can you try upgrading react-native-svg-transformer to the just released v0.14.0 ?
kristerkari/react-native-svg-transformer#54 (comment)

@harshitaahuja
Copy link

@msand yes it fixed the background issue but introduced a new issue where fill atribute is no longer working. I will take that issue there. thanks

JackWillie added a commit to JackWillie/react-native-svg that referenced this issue Nov 27, 2022
# [9.12.0](software-mansion/react-native-svg@v9.11.1...v9.12.0) (2019-10-19)

### Bug Fixes

* handle setting transform attribute on clipPath, fixes [#1152](software-mansion/react-native-svg#1152) ([73b21d1](software-mansion/react-native-svg@73b21d1))
* improve handling of transform attribute on clipPath, fixes [#1152](software-mansion/react-native-svg#1152) ([3aa126e](software-mansion/react-native-svg@3aa126e))
* **ios:** backwards compatible RCTImageLoader.h handling fixes [#1141](software-mansion/react-native-svg#1141) ([3c22c97](software-mansion/react-native-svg@3c22c97))
* **ios:** clipPath rendering, fixes [#1131](software-mansion/react-native-svg#1131) ([2534537](software-mansion/react-native-svg@2534537))
* **ios:** deprecation of RCTImageLoader fixes [#1141](software-mansion/react-native-svg#1141) ([5452144](software-mansion/react-native-svg@5452144))
* **ios:** fix changes in color/currentColor/tintColor, fixes [#1151](software-mansion/react-native-svg#1151) ([0c7e94d](software-mansion/react-native-svg@0c7e94d))
* **ios:** image viewBox opposite handling of y alignment, fixes [#1138](software-mansion/react-native-svg#1138) ([c69e9e2](software-mansion/react-native-svg@c69e9e2))
* **js:** allow setting stopColor/Opacity/Offset using styles, fix [#1153](software-mansion/react-native-svg#1153) ([5984e06](software-mansion/react-native-svg@5984e06))
* getPointAtLength signature ([2c57af2](software-mansion/react-native-svg@2c57af2))
* getScreenCTM calculation ([5c5072d](software-mansion/react-native-svg@5c5072d))
* improve native method spec conformance ([c63f9e2](software-mansion/react-native-svg@c63f9e2))
* improve types for getBBox ([cecde7d](software-mansion/react-native-svg@cecde7d))
* prepare script ([9a3dc4e](software-mansion/react-native-svg@9a3dc4e))
* **ios:** memory leak in tspan, fixes [#1073](software-mansion/react-native-svg#1073) ([974f3a8](software-mansion/react-native-svg@974f3a8))
* fix native methods spec conformance ([ecedb21](software-mansion/react-native-svg@ecedb21))
* Make native methods synchronous ([8ce7611](software-mansion/react-native-svg@8ce7611))
* refine types for matrix helpers ([409af91](software-mansion/react-native-svg@409af91))
* refine types for matrix helpers ([7a3f867](software-mansion/react-native-svg@7a3f867))
* **android:** defineMarker/getDefinedMarker storage ([e6eda84](software-mansion/react-native-svg@e6eda84))
* **android:** native method scaling and getScreenCTM offset ([f3e0b19](software-mansion/react-native-svg@f3e0b19))
* native method signatures web compatibility / spec conformance ([8687a3d](software-mansion/react-native-svg@8687a3d))
* **ios:** optimize extractPathData, clear PathMeasure when no textPath ([df69c26](software-mansion/react-native-svg@df69c26))

### Features

* **flow:** add flowgen to generate flow types from typescript, [#1125](software-mansion/react-native-svg#1125) ([fcd66fb](software-mansion/react-native-svg@fcd66fb))
* implement getBBox, getCTM, getScreenCTM ([f13d54a](software-mansion/react-native-svg@f13d54a))
* implement isPointInStroke ([2ba64df](software-mansion/react-native-svg@2ba64df))
* initial implementation of isPointInFill ([203e53b](software-mansion/react-native-svg@203e53b))
* support using native methods using promises instead of callbacks ([c28499b](software-mansion/react-native-svg@c28499b))
* **android:** implement getTotalLength and getPointAtLength ([cd667d0](software-mansion/react-native-svg@cd667d0))
* **ios:** implement getTotalLength and getPointAtLength ([78c4f20](software-mansion/react-native-svg@78c4f20))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment