react-native-share: react-native@0.62.x crash for base64 urls sharing on iOS platform

Steps to reproduce

  1. Use react-native@0.62.2 and react-native-share@3.3.3
  2. Try to share an image with this code:
        await Share.open({
          url: `data:image/jpg;base64,${<any base64 image code here>}`,
        });
  1. iOS Application will be crashed with logs:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSURLResponse allHeaderFields]: unrecognized selector sent to instance 0x600001d57120'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff23e3cf0e __exceptionPreprocess + 350
	1   libobjc.A.dylib                     0x00007fff50ba89b2 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff23e5dc34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
	3   CoreFoundation                      0x00007fff23e4190c ___forwarding___ + 1436
	4   CoreFoundation                      0x00007fff23e43bf8 _CF_forwarding_prep_0 + 120
	5   Brandgility                         0x00000001030a8acc +[SKResponseInfo shouldStripReponseBodyWithResponse:] + 76
	6   Brandgility                         0x00000001030a89a1 -[SKResponseInfo initWithIndentifier:timestamp:response:data:] + 241
	7   Brandgility                         0x0000000103082779 __71-[FLEXNetworkRecorder recordLoadingFinishedWithRequestID:responseBody:]_block_invoke + 825
	8   libdispatch.dylib                   0x00000001067a1f11 _dispatch_call_block_and_release + 12
	9   libdispatch.dylib                   0x00000001067a2e8e _dispatch_client_callout + 8
	10  libdispatch.dylib                   0x00000001067a96fd _dispatch_lane_serial_drain + 788
	11  libdispatch.dylib                   0x00000001067aa28f _dispatch_lane_invoke + 422
	12  libdispatch.dylib                   0x00000001067b5b65 _dispatch_workloop_worker_thread + 719
	13  libsystem_pthread.dylib             0x00007fff51c08a3d _pthread_wqthread + 290
	14  libsystem_pthread.dylib             0x00007fff51c07b77 start_wqthread + 15
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

Expected behaviour

IOS application successfully launches Share modal

Actual behaviour

IOS application crashes

Environment

  • react-native@0.62.2:
  • iOS 13.5.1

react-native-share

react-native-share@3.3.3

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 38

Most upvoted comments

I’m testing the example App with #803 and apparently I’m having the same problem when I’m trying to share any Image with base64 with rn@62.2. 🤔

Did you get anything about that @Kta-M , @arrygoo ?

Edit:

I tested the suggestion from https://github.com/react-native-community/react-native-share/issues/789#issuecomment-636280258 and the example app is now working without any problem. 🎉

Can you try that @oleksandr-dziuban ?

This may have been the cause 👀 #789 (comment)

Thanks for sharing this. I will give a try updating the example project to this version.

@oleksandr-dziuban would you mind testing this on your project? Unfortunately, I need to update the example to 0.62.2. 😅

I didn’t try file:// because I’m using screenshots in base64 from react-native-view-shot. Double checked if base64 code correct, yes it is. Also tried to hardcode simple base64 image without react-native-view-shot. Same crash

@MateusAndrade Haha, how the Flipper can affect base64 images flow? Really weird… but yes, it helps

Yes, I added jpg option to be a default for view-shot. Double checked. Just output was a base64. Changed to default ‘tmpfile’ and it’s OK to use with rn-share. So something wen wrong with sharing base64 in RN 0.62+. This is correct format data:image/jpg;base64,, I used it successfully on RN 0.61.5

@MateusAndrade I will use this way for now, but issue with base64 still exists anyway. Thanks a lot for your help, I’m unblocked at least with current migration to latest react-native. Thank you!

@MateusAndrade Tried your way to capture a file (not a base64) with view-shot - works fine! So url as file works fine, but url as base64 is broken for react-native@0.62.2

@MateusAndrade Added crash logs here…