question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Svg file with mask not working

See original GitHub issue

Behaviour

Svg files including masks are rendered in low quality/pixelated. The following screenshot includes an svg with and without masks: screenshot

Expected behaviour

It is expected that the library can render all valid svg’s. Putting the XML content of SvgWithMask.svg (see example project) into this online svg renderer looks fine, but rendering it using react-native-svg looks pixelated.

Environment info

React native info output:

System:
    OS: macOS 10.15.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 386.13 MB / 32.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 10.16.0 - /usr/local/bin/node
    Yarn: 1.19.2 - ~/.yarn/bin/yarn
    npm: 6.13.4 - /usr/local/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.8.4 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 13.4, DriverKit 19.0, macOS 10.15, tvOS 13.4, watchOS 6.2
    Android SDK:
      API Levels: 19, 23, 24, 25, 26, 27, 28, 29
      Build Tools: 23.0.1, 23.0.3, 25.0.1, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.3, 27.0.3, 28.0.0, 28.0.0, 28.0.2, 28.0.3, 29.0.2
      System Images: android-19 | Google APIs ARM EABI v7a, android-19 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 3.6 AI-192.7142.36.36.6241897
    Xcode: 11.4.1/11E503a - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_172 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.2 => 0.62.2
  npmGlobalPackages:
    *react-native*: Not Found

Library version: 12.1.0

Steps To Reproduce

An example project with the bug can be found here and instructions for running the example can be found in the example’s README.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:8

github_iconTop GitHub Comments

3reactions
joebochillcommented, Jul 6, 2021

I too am having the same issue with masks causing a blurred effect.

As @beshur suggested, increasing the size of the viewbox definition for the SVG works as a temporary workaround. If the svg is used at a size that is ~2-3x the size of the viewbox, you start to notice the blurred edges of the mask.

We have a bunch of svg icons that are defined on a 24px viewbox and it would be nice to not have to update all of their viewboxes in order to use them.

3reactions
sheshnathiicmrcommented, Nov 22, 2020

reminding bot not to stale, I am facing the same

Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG: Mask not working as expected - Stack Overflow
1 Answer 1 ... SVG is not like CSS, it doesn't use the stroke-width when calculating dimensions for masks and filters, so you...
Read more >
Svg file with mask not working · Issue #1377 - GitHub
svg (see example project) into this online svg renderer looks fine, but rendering it using react-native-svg looks pixelated.
Read more >
SVG Mask Problem - GSAP - GreenSock
I'm applying a mask in an SVG per the link below but it's not working. https://developer.mozilla.org/en-US/docs/Web/SVG/Element/mask.
Read more >
SVG mask not working - Graphic Design Stack Exchange
For this I've made 5 SVG masks. All of them seem to be working (i.e. masking their respective object), except for one! I'm...
Read more >
SVG objects with masks not appearing - Natron - pixls.us
Try putting the SVG in a zip file and upload. nul April 27, 2021, 8: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found