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

Failed to snapshot view tag XXXX

Open FernandoAOborges opened this issue 1 year ago • 25 comments

 @gorhom/[email protected]
│ ├─┬ @gorhom/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ @miblanchard/[email protected]
│ └── [email protected] deduped
├─┬ @notifee/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-async-storage/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-community/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-community/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-community/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-firebase/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-google-signin/[email protected]
│ └── [email protected] deduped
├─┬ @react-native-menu/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ ├─┬ @react-navigation/[email protected]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @react-navigation/[email protected]
│ └── [email protected] deduped
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ @testing-library/[email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected] deduped
│ └── [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]
│ └── [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]
│ │ └── [email protected] deduped
│ └── [email protected] deduped
└─┬ [email protected]
  └── [email protected] deduped
[email protected]
react-native-view-shot": "^3.8.0"

Platform: Android

Expected Behavior The captureScreen function in react-native-view-shot should capture an image of the screen and return the URI of the captured image.

Actual Behavior When calling captureScreen, the following error occurs: Failed to snapshot view tag 2730.

Steps to Reproduce the Behavior Install the latest version of react-native-view-shot. Set up and implement screen capture with captureScreen.

Run the app on Android with React Native version 0.76.1.
The error Failed to snapshot view tag 2730 appears when trying to capture the screen.

FernandoAOborges avatar Oct 31 '24 13:10 FernandoAOborges

still same error for me also , in the version of [email protected](Bridgeless) also, in the version 0.74.5 (normal) it is worked fine iam also surfing for the solution from couple of days, the error is (NOBRIDGE) ERROR Error capturing view: [Error: Failed to snapshot view tag 872]

ChetanReddyC avatar Nov 02 '24 08:11 ChetanReddyC

I got the same error, here's my log cat:

Failed to snapshot view tag xxxx
                                                                                                    java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.react.uimanager.UIManagerModule.addUIBlock(com.facebook.react.uimanager.UIBlock)' on a null object reference
                                                                                                    	at fr.greweb.reactnativeviewshot.RNViewShotModule.captureRef(RNViewShotModule.java:104)
                                                                                                    	at com.facebook.jni.NativeRunnable.run(Native Method)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:232)
                                                                                                    	at android.os.Looper.loop(Looper.java:317)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)

auliakbarh avatar Nov 02 '24 10:11 auliakbarh

Hello

Same error here with latest react-native.

What s the best RN version to use for this module ?

Thanks

smolleyes avatar Nov 06 '24 09:11 smolleyes

@gre have an idear please ? this is the last step to finish my app and i fail on this , so frustrating lol

thanks

smolleyes avatar Nov 06 '24 11:11 smolleyes

@gre have an idear please ? this is the last step to finish my app and i fail on this , so frustrating lol

thanks

I had to switch packages because it was urgent. I changed to @shopify/react-native-skia, snapshot.

FernandoAOborges avatar Nov 06 '24 11:11 FernandoAOborges

@FernandoAOborges yeah i tried it yesterday but it returned "Textnodes are not yet supported", strange...

smolleyes avatar Nov 06 '24 12:11 smolleyes

Hello

Same error here with latest react-native.

What s the best RN version to use for this module ?

Thanks

Iam currently using this in the RN version 0.74.5 in this version this is working fine as it suppose to! ,even i upgraded to next version of this this isn't working,iam also waiting for this fix to upgrade to RN latest no bridge architecture, everything is working except this package, hope this will be fixed soon!

ChetanReddyC avatar Nov 06 '24 13:11 ChetanReddyC

I got the same error

duongnguyen17 avatar Nov 07 '24 03:11 duongnguyen17

Same error

eduardo-manoel-de-lara avatar Nov 18 '24 15:11 eduardo-manoel-de-lara

Receive this error when switching to Expo 52

du1nabozny avatar Nov 18 '24 21:11 du1nabozny

Same issue when I upgraded to Expo53

arisa-s avatar Nov 20 '24 07:11 arisa-s

same issue.

samanmadani71 avatar Nov 21 '24 16:11 samanmadani71

Same issue: (NOBRIDGE) LOG [Error: Failed to snapshot view tag 36]

expo: 52.0.11 react-native: 0.76.3 react-native-view-shot: 4.0.2

linushahs avatar Nov 23 '24 16:11 linushahs

Same here

Tsabary avatar Nov 25 '24 13:11 Tsabary

Same error:Failed to snapshot view tag 36 iOS works well, but Android doesn't work as well.

lisy999 avatar Dec 01 '24 15:12 lisy999

same issue here on friday it was working with expo: "^51.0.38", react-native: "0.74.5" and react-native-view-shot: "^3.8.0" yesterday we updated to expo: "^52.0.0", react-native: "0.76.3", react-native-view-shot: "^4.0.2" and it stopped working on Android haven't been able to test on iOS yet

parmaps avatar Dec 02 '24 20:12 parmaps

I have created a patch to fix this issue, see: https://github.com/gre/react-native-view-shot/issues/555

senseFy avatar Jan 16 '25 13:01 senseFy

I am on react-native-view-shot: "^4.0.3" and "expo": "~52.0.9", and it works for me on Android (Samsung, Android 14) . There is no change between 4.0.2 and 4.0.3 on Android. So I wonder if it never works for you guys? Or at what use cases? What phone devices?

CptFabulouso avatar Jan 17 '25 11:01 CptFabulouso

Same here

PepeTonin avatar Jan 22 '25 19:01 PepeTonin

I am on react-native-view-shot: "^4.0.3" and "expo": "~52.0.9", and it works for me on Android (Samsung, Android 14) . There is no change between 4.0.2 and 4.0.3 on Android. So I wonder if it never works for you guys? Or at what use cases? What phone devices?

Can you share your implementation? I am on react-native-view-shot: "^4.0.3" and "expo": "~52.0.31". It works great on iOS but I get this same error on Android.

jkincheloe33 avatar Feb 17 '25 20:02 jkincheloe33

Pretty basic:

function CaptureView() {
  const viewShotRef = useRef<ViewShot | null>(null);
  return (
    <View style={{ flex: 1 }}>
      <ViewShot
        ref={viewShotRef}
        options={props.imageOptions || DEFAULT_IMAGE_OPTIONS}
        style={styles.flex}
      >
        <View
          style={{
            flex: 1,
            backgroundColor: 'green',
            justifyContent: 'center',
            alignItems: 'center',
          }}
        >
          <View style={{ width: 100, height: 100, backgroundColor: 'red' }} />
        </View>
      </ViewShot>
      <Button
        title="Capture"
        onPress={() => {
          viewShotRef.current
            ?.capture?.()
            .then((uri) => {
              console.log(uri);
            })
            .catch(console.error);
        }}
      />
    </View>
  );
}

I have not run it on production build yet, but I see no mention it's just a production problem. You guys are using new arch, right?

CptFabulouso avatar Feb 18 '25 08:02 CptFabulouso

@CptFabulouso Was able to get it working thanks! Seems to be fixed in this release now.

jkincheloe33 avatar Feb 18 '25 15:02 jkincheloe33

I've fixed this error, by removing "fileName" property from "options".

petrohusak avatar Feb 21 '25 09:02 petrohusak

I fixed by wrapping my component with this <ViewShot ref={viewShotRef} options={{ format: 'jpg', quality: 0.9 }}> and using const imageURI = await viewShotRef.current.capture(); it worked for me after many days of debugging, i hope this will help someone

Accoladecreative avatar Mar 23 '25 14:03 Accoladecreative

y

I got the same error, here's my log cat:

Failed to snapshot view tag xxxx
                                                                                                    java.lang.NullPointerException: Attempt to invoke virtual method 'void com.facebook.react.uimanager.UIManagerModule.addUIBlock(com.facebook.react.uimanager.UIBlock)' on a null object reference
                                                                                                    	at fr.greweb.reactnativeviewshot.RNViewShotModule.captureRef(RNViewShotModule.java:104)
                                                                                                    	at com.facebook.jni.NativeRunnable.run(Native Method)
                                                                                                    	at android.os.Handler.handleCallback(Handler.java:959)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:100)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:232)
                                                                                                    	at android.os.Looper.loop(Looper.java:317)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl.lambda$startNewBackgroundThread$2(MessageQueueThreadImpl.java:217)
                                                                                                    	at com.facebook.react.bridge.queue.MessageQueueThreadImpl$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)

I experienced the same as well! this fixed it for me. I had to manually apply the patch though. https://github.com/gre/react-native-view-shot/issues/555#issue-2792705792

tkud04 avatar May 09 '25 17:05 tkud04