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.

Masked images do not render on Android

See original GitHub issue

I’m using the react-native-figma-squircle package alongside this package, for whatever reason the following code renders nothing of the underlying image at all on Android, however it works perfectly fine on iOS:

type Props = { uri: string; size: number; style?: ViewStyle };

function PerkLogo({ uri, size, style }: Props) {
  const dimensionsStyle = { width: size, height: size };

  return (
    <View style={[styles.imageContainer, dimensionsStyle, style]}>
      <MaskedView
        // style={[mainStyles.overflowHidden]}
        maskElement={
          <SquircleView
            style={StyleSheet.absoluteFill}
            squircleParams={{
              cornerSmoothing: 1,
              fillColor: colors.white,
              cornerRadius: 30,
            }}
          />
        }>
        <Image source={{ uri: CDN(uri) }} style={[styles.image, dimensionsStyle]} />
      </MaskedView>
    </View>
  );
}

const styles = StyleSheet.create({
  imageContainer: {
    // backgroundColor: '#fff',
    borderRadius: defaultBorderRadius,
    overflow: 'hidden',
  },
  image: {
    ...mainStyles.imageBorderRadius,
    resizeMode: 'contain',
  },
});

react-native: 0.63.3 react-native-masked-view: 0.2.5 react-native-figma-squircle: 0.1.2

I’ve wasted hours on this between forcing a re-render using a key prop on MaskedView to changing all the styles of every element in this code. Every once in a while randomly the image shows up when I navigate away from the screen using this component. Otherwise it seems to be completely broken on Android.

Any suggestions? Is this a known bug on Android with image masking?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:10
  • Comments:7

github_iconTop GitHub Comments

3reactions
lyubo-andcommented, Jul 8, 2022

Have you tried applying the prop androidRenderingMode introduced in this PR

<MaskedView androidRenderingMode="software" {...{ maskElement }}>
...
</MaskedView>
1reaction
perroudskycommented, Jul 8, 2022

thanks @lyubo-and it looks like its working for me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Image as a mask for another image not rendering on Android
Trying to apply some image shape masking using .png image. Everything works as expected on iOS, but android doesn't render anything, just empty....
Read more >
Android Image Masking not rendering as intended
UPDate : I tried the mask Image from the blog post with my own JPEG . IT works perfect so the issue is...
Read more >
Masking Bitmaps. The problem of image masking often…
The problem of image masking often comes up in Android development. Rounded image corners or rounded images are required most of all.
Read more >
CSS image mask only works on Firefox for Android - Reddit
I've been trying to apply an image mask to a div, but it only seems to be working on a single browser: Firefox...
Read more >
-webkit-mask-box-image - CSS: Cascading Style Sheets | MDN
Non-standard: This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it...
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