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

The view cannot be captured. drawViewHierarchyInRect was not successful. This is a potential technical or security limitation.

Open daheeahn opened this issue 1 year ago • 7 comments

I faced these errors What is the error and how can I fix it?

my code

captureRef.current.capture()
  .then(uri => {
    // success
  })
  .catch(e => {
    // fail
    console.log(e);
  });

error

 {"code":"EUNSPECIFIED","message":"The view cannot be captured. drawViewHierarchyInRect was not successful. This is a potential technical or security limitation.","domain":"RCTErrorDomain","userInfo":null,"nativeStackIOS":["0   roubit                              0x0000000100a3be18 _ZN8facebook5react11JSIExecutor21defaultTimeoutInvokerERKNSt3__18functionIFvvEEENS3_IFNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvEEE + 676124","1   roubit                              0x0000000100a12db4 _ZN8facebook5react11JSIExecutor21defaultTimeoutInvokerERKNSt3__18functionIFvvEEENS3_IFNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvEEE + 508088","2   roubit                              0x0000000100cf80c0 __cxa_throw + 1658776","3   roubit                              0x0000000100a37384 _ZN8facebook5react11JSIExecutor21defaultTimeoutInvokerERKNSt3__18functionIFvvEEENS3_IFNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvEEE + 657032","4   roubit                              0x0000000100a37474 _ZN8facebook5react11JSIExecutor21defaultTimeoutInvokerERKNSt3__18functionIFvvEEENS3_IFNS2_12basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEEvEEE + 657272","5   libdispatch.dylib                   0x000000019995c320 B74732B5-D7FE-34A4-9346-41945701F020 + 8992","6   libdispatch.dylib                   0x000000019995deac B74732B5-D7FE-34A4-9346-41945701F020 + 16044","7   libdispatch.dylib                   0x000000019996c6a4 B74732B5-D7FE-34A4-9346-41945701F020 + 75428","8   libdispatch.dylib                   0x000000019996c2f4 _dispatch_main_queue_callback_4CF + 44","9   CoreFoundation                      0x000000019252dd18 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 625944","10  CoreFoundation                      0x000000019250f650 6A07CBE8-4F65-3DBC-B59D-C1A188A7B95D + 501328","11  CoreFoundation                      0x00000001925144dc CFRunLoopRunSpecific + 612","12  GraphicsServices                    0x00000001cd77435c GSEventRunModal + 164","13  UIKitCore                           0x00000001948a037c B0858D8E-7220-37BF-873F-ECC2B0A358C3 + 3789692","14  UIKitCore                           0x000000019489ffe0 UIApplicationMain + 340","15  roubit                              0x0000000100578ba4 roubit + 19364","16  dyld                                0x00000001b199cdec 41605DC7-F412-37D1-B51B-FEE1A26701E9 + 89580"]}

daheeahn avatar Jun 07 '23 08:06 daheeahn

const filepath = await captureRef(viewShotRef, {
     format: 'jpg',
     quality: 0.9,
     useRenderInContext: true,
});

<ViewShot ref={viewShotRef}>
          ...
</ViewShot>         

captureRef was the solution for me

iliapnmrv avatar Nov 13 '23 17:11 iliapnmrv

The same error for IOS

[Error: The view cannot be captured. drawViewHierarchyInRect was not successful. This is a potential technical or security limitation.]
"react-native": "0.72.7",

Akyna avatar Dec 04 '23 08:12 Akyna

const filepath = await captureRef(viewShotRef, {
     format: 'jpg',
     quality: 0.9,
     useRenderInContext: true,
});

<ViewShot ref={viewShotRef}>
          ...
</ViewShot>         

captureRef was the solution for me

It didn't fix the error for me

Akyna avatar Dec 04 '23 08:12 Akyna

@Akyna can you please share more data? "react-native": "0.72.7" works fine for me

iliapnmrv avatar Dec 04 '23 09:12 iliapnmrv

@Akyna can you please share more data? "react-native": "0.72.7" works fine for me

"react-native-view-shot": "^3.8.0",

cc @iliapnmrv

Akyna avatar Dec 04 '23 10:12 Akyna

@iliapnmrv this help

useRenderInContext: true,

Thx!

Akyna avatar Dec 04 '23 10:12 Akyna