react-native-view-shot icon indicating copy to clipboard operation
react-native-view-shot copied to clipboard

Error: Failed to capture view snapshot on React Native 0.72.0

Open n-ii-ma opened this issue 1 year ago • 13 comments

bug report

After upgrading to React Native 0.72.0, I get the Failed to capture view snapshot error.

It worked on React Native 0.71.11

Version & Platform

[email protected] /Users/vedadi/Aria
├─┬ @gorhom/[email protected]
│ ├─┬ @gorhom/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ @notifee/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-async-storage/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-clipboard/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-community/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-firebase/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-masked-view/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ ├─┬ @react-navigation/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ @sentry/[email protected]
│ └── [email protected] deduped
├─┬ [email protected] (git+ssh://[email protected]/aria-khodro/react-native-background-timer.git#18cc30364d35492e2e5d6390f0b61fb9544d022f)
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected] (git+ssh://[email protected]/aria-khodro/react-native-modern-datepicker.git#1262b655a4585300bdb71043ebe0e11ffa391ecc)
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected] (git+ssh://[email protected]/aria-khodro/react-native-qrcode-svg.git#fbef3350002dc9a921fee1fc281886abdd5a908b)
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └─┬ @react-native/[email protected]
│   └── [email protected] deduped
└─┬ [email protected]
  └── [email protected] deduped

Platform: Only happens on Android

n-ii-ma avatar Jun 24 '23 13:06 n-ii-ma

expriencing same issue, no error occured and no uri has produced, expo sdk 49 react native 72.3 with new arch

arasrezaei avatar Jul 14 '23 06:07 arasrezaei

expriencing same issue, no error occured and no uri has produced, expo sdk 49 react native 72.3 with new arch

Finally someone else reports this issue! I don't think this package is actively maintained anymore.

Would appreciate if anyone recommends an alternate package that works with new versions of RN.

n-ii-ma avatar Jul 15 '23 05:07 n-ii-ma

Any update on this? I am facing the same issue on Android.

Shankulkarni avatar Jul 19 '23 13:07 Shankulkarni

I'm facing the same issue in android

 ERROR  Oops, snapshot failed [Error: Failed to capture view snapshot]

timothyerwin avatar Jul 21 '23 19:07 timothyerwin

Until this package is updated in order to become compatible with RN v0.72+, it should be considered obsolete.

n-ii-ma avatar Jul 24 '23 09:07 n-ii-ma

I had this problem, but this seems to have fixed it for me: https://github.com/gre/react-native-view-shot/issues/7#issuecomment-521379462

paulsonnenschein avatar Jul 26 '23 15:07 paulsonnenschein

Adding collapsable={false} to the View component which you want to capture temporarily fixes this issue.

Thanks to @paulsonnenschein (https://github.com/gre/react-native-view-shot/issues/482#issuecomment-1652097803) for pointing to the solution: https://github.com/gre/react-native-view-shot/issues/7#issuecomment-521379462

n-ii-ma avatar Jul 30 '23 08:07 n-ii-ma

Can anyone tell me if they able to get the solution for this issue it is urgent for me to do that if there are any library which can replace this library then you can tell me

Akshaybagai52 avatar Aug 30 '23 11:08 Akshaybagai52

Can anyone tell me if they able to get the solution for this issue it is urgent for me to do that if there are any library which can replace this library then you can tell me

Did you try adding collapsable={false} to the View component which you want to capture?

n-ii-ma avatar Sep 03 '23 07:09 n-ii-ma

I'm using ImageBackground from react-native and continue to encounter the error on Android, even after setting collapsible to false. However, it works perfectly on iOS.

<ImageBackground
    ref={viewRef}
    collapsable={false}
    source={{ uri: themeUriPath }}
    style={{ height: '100%', width: '100%' }}
>
    {renderLayers()}
</ImageBackground>

nijarv avatar Oct 16 '23 08:10 nijarv

Adding collapsable={false} to the View component which you want to capture temporarily fixes this issue.

Thanks to @paulsonnenschein (#482 (comment)) for pointing to the solution: #7 (comment)

I've checked this solution and it won't work for me (iOS was OK but android had an error). I had to change View to the ViewShot tag, and it started working.

dominik-mrugalski avatar Jan 25 '24 15:01 dominik-mrugalski

To me, unbelievable, what worked was removing a negative margin left from Video component.

import { Video } from 'expo-av'
 ....
return (
  <Video
    source={{ uri: props.url }}
    style={{
      position: 'absolute',
      top: 0,
      left: 0,
      width: '100%',
      height: '100%',
      marginLeft: '-10%',
    }}
  />
);

This way, always that the video is on screen, the error [Error: Failed to capture view snapshot] occurs.

After remove the marginLeft, came back to works fine o.O

fabiiomariiano avatar Jun 13 '24 19:06 fabiiomariiano

Adding collapsable={false} to the View component which you want to capture temporarily fixes this issue.

Thanks to @paulsonnenschein (#482 (comment)) for pointing to the solution: #7 (comment)

Setting Collapsible to false is also not working, is there any alternative?

JaifDev avatar Aug 04 '24 07:08 JaifDev