Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-native@0.62.x crash for base64 urls sharing on iOS platform #797

Closed
oleksandr-dziuban opened this issue Jun 11, 2020 · 38 comments
Closed
Labels
bug help wanted os: ios stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@oleksandr-dziuban
Copy link
Collaborator

oleksandr-dziuban commented Jun 11, 2020

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

@MateusAndrade
Copy link
Collaborator

Can you share the iOS logs @oleksandr-dziuban ?

@oleksandr-dziuban
Copy link
Collaborator Author

oleksandr-dziuban commented Jun 11, 2020

@MateusAndrade @mikehardy Could you please check this issue? Thanks a lot

@oleksandr-dziuban
Copy link
Collaborator Author

@MateusAndrade Added crash logs here..

@MateusAndrade
Copy link
Collaborator

MateusAndrade commented Jun 11, 2020

Does this only happen when sharing a url with a base64? Also, can you confirm if this happens with the master version or v3.1.2?

@oleksandr-dziuban
Copy link
Collaborator Author

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

@oleksandr-dziuban
Copy link
Collaborator Author

Installing 3.1.2... one minute

@oleksandr-dziuban
Copy link
Collaborator Author

oleksandr-dziuban commented Jun 11, 2020

@MateusAndrade
Same crash on v3.1.2 with react-native@0.62.2
On react-native@0.61.5 everything works fine on react-native-share@3+.
So the reason in some new changes in latest react-native@0.62+ platform

@MateusAndrade
Copy link
Collaborator

Same crash on v3.1.2.
On react-native@0.61.5 everything works fine on react-native-share@3+.
So the reason in some new changes in latest react-native@0.62+ platform

Strange, so with 3.3.3 it runs without any problem with rn@61.5?

@oleksandr-dziuban
Copy link
Collaborator Author

oleksandr-dziuban commented Jun 11, 2020

Didn't test 3.3.3 on 0.61.5.
I'm migrating project now from react-native@0.61.5 to 0.62.2
And made regression testing on basic areas. So on 0.61.5 I used react-native-share@3.0.0 and it worked fine

@oleksandr-dziuban
Copy link
Collaborator Author

Will try 3.0.0 with 0.62.2...

@MateusAndrade
Copy link
Collaborator

Didn't test 3.3.3 on 0.61.5.
I'm migration project now from react-native@0.61.5 to 0.62.2
And made regression testing on basic areas. So on 0.61.5 I used react-native-share@3.0.0 and it worked fine

Strange, I'm using an older version(2.0.0) with rn@62.2 with any problem. I'm using the same approach with rn-view-shot here. Did you try passing a type?

@oleksandr-dziuban
Copy link
Collaborator Author

@MateusAndrade
Nope, same crash for me on 3.0.0

@oleksandr-dziuban
Copy link
Collaborator Author

oleksandr-dziuban commented Jun 11, 2020

It works fine without type on 0.61.5

I also use TrustKit for certificates pinning. Can it affect Share functionality? I see something weird in crash logs regarding network calls..

@MateusAndrade
Copy link
Collaborator

It works fine without type on 0.61.5

I also use TrustKit for certificates pinning. Can it affect Share functionality? I see something weird in crash logs regarding network calls..

I don't know, I never had to use TrustKit. Would you mind disabling that to test this? Also I tested here with rn@62.2 and rn-share@2.00 It ti works fine. I need to test with a newer version to ensure this is working. 😅

Also, I'm using something like this:

Share.open({ type, message, url })

@oleksandr-dziuban
Copy link
Collaborator Author

oleksandr-dziuban commented Jun 11, 2020

What is type? image/jpg or just jpg?
I tried type: 'jpg', nothing new...

@MateusAndrade
Copy link
Collaborator

What is type? image/jpg or just jpg?
I tried type: 'jpg', nothing new...

I noted that you are setting the type. But I'm calling the capture from rn-view-shot passing the uri directly to the share function. Something like this:

capture.then(uri => Share.open({ uri }))

Can you confirm if this works for you? Also, I need to confirm, but the right one probably is image/jpg.

@oleksandr-dziuban
Copy link
Collaborator Author

Tried to disable Truskit, pass type - nothing

@oleksandr-dziuban
Copy link
Collaborator Author

oleksandr-dziuban commented Jun 11, 2020

view-shot return pure base64 string. We need to add data:image/jpg;base64,${uri} here as described in rn-share docs

@oleksandr-dziuban
Copy link
Collaborator Author

Just tested v2.0.0, same crash for me...

@oleksandr-dziuban
Copy link
Collaborator Author

@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

@oleksandr-dziuban
Copy link
Collaborator Author

@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!

@oleksandr-dziuban oleksandr-dziuban changed the title react-native@0.62.x is not supported react-native@0.62.x is not supported for base64 urls on iOS platform Jun 11, 2020
@oleksandr-dziuban oleksandr-dziuban changed the title react-native@0.62.x is not supported for base64 urls on iOS platform react-native@0.62.x crash for base64 urls sharing on iOS platform Jun 11, 2020
@MateusAndrade
Copy link
Collaborator

MateusAndrade commented Jun 11, 2020

@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

Great! Actually, wich can be wrong is: ````data:image/jpg;base64,```. I didn't test this using your approach, but maybe you are overriding the image type or something like that. Looking at the docs from view-shot, you can pass an optional format.

Can you check with is the format of the output from your project? 👯

Edit:

I did it a quick check at the docs of view-shot, and the default export from the capture is png.

format (string): either png or jpg or webm (Android). Defaults to png.

I'm not certain about that, but maybe when you set a type jpg which was originally a png can cause some errors.

@oleksandr-dziuban
Copy link
Collaborator Author

oleksandr-dziuban commented Jun 11, 2020

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

@arrygoo
Copy link

arrygoo commented Jun 12, 2020

I can replicate this error, even the example in examples where it loads a hardcoded base64 fails on RN62

@Kta-M
Copy link

Kta-M commented Jun 14, 2020

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

@MateusAndrade
Copy link
Collaborator

MateusAndrade commented Jun 15, 2020

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. 😅

@MateusAndrade
Copy link
Collaborator

MateusAndrade commented Jun 17, 2020

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 #789 (comment) and the example app is now working without any problem. 🎉

Can you try that @oleksandr-dziuban ?

@oleksandr-dziuban
Copy link
Collaborator Author

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

@MateusAndrade
Copy link
Collaborator

MateusAndrade commented Jun 17, 2020

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

I don't have any idea, I was thinking of looking at the flipper repo but I'm without time this week. Also, can we close this issue?

@krzysztofnowak
Copy link

Hi guys. Any progress on this? Having same issue, but not using Flipper in my project

@MateusAndrade
Copy link
Collaborator

Hi guys. Any progress on this? Having same issue, but not using Flipper in my project

Can you share your Podfile and your package.json?

@krzysztofnowak
Copy link

Hi guys. Any progress on this? Having same issue, but not using Flipper in my project

Can you share your Podfile and your package.json?

dependencies from package.json

"devDependencies": {
    "@babel/core": "^7.6.2",
    "@babel/runtime": "^7.6.2",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/enzyme": "^3.1.4",
    "@types/enzyme-adapter-react-16": "^1.0.1",
    "@types/jest": "^21.1.6",
    "@typescript-eslint/eslint-plugin": "^2.34.0",
    "@typescript-eslint/eslint-plugin-tslint": "^2.34.0",
    "@typescript-eslint/parser": "^2.34.0",
    "axios-mock-adapter": "1.17.0",
    "babel-jest": "24.9.0",
    "concurrently": "^5.2.0",
    "detox": "14.3.4",
    "enzyme": "3.10.0",
    "enzyme-adapter-react-16": "1.15.1",
    "eslint": "^7.0.0",
    "eslint-plugin-import": "^2.21.2",
    "eslint-plugin-jsdoc": "^25.4.2",
    "eslint-plugin-prefer-arrow": "^1.2.1",
    "eslint-plugin-prettier": "^3.1.4",
    "husky": "^3.1.0",
    "jest": "24.9.0",
    "jest-coverage-ratchet": "^0.2.3",
    "jetifier": "^1.6.4",
    "metro-react-native-babel-preset": "0.56.0",
    "prettier": "^2.0.5",
    "react-dom": "16.6.0",
    "react-native-swipe-gestures": "^1.0.2",
    "react-native-typescript-transformer": "^1.1.4",
    "react-test-renderer": "16.9.0",
    "sharp": "^0.23.3",
    "typescript": "3.4.1"
  },
  "optionalDependencies": {
    "fsevents": "^1.2.9"
  },
  "dependencies": {
    "@react-native-community/async-storage": "^1.7.1",
    "@react-native-community/netinfo": "^4.2.0",
    "@types/color": "^2.0.0",
    "@types/crypto-js": "^3.1.37",
    "@types/d3-scale": "^1.0.10",
    "@types/lodash": "^4.14.85",
    "@types/react": "^16.9.23",
    "@types/react-intl": "^2.3.2",
    "@types/react-native": "^0.61.23",
    "@types/react-native-fbsdk": "^1.0.0",
    "@types/react-native-i18n": "^2.0.0",
    "@types/react-native-safari-view": "^2.0.2",
    "@types/react-native-version-number": "^0.3.0",
    "@types/react-redux": "^5.0.13",
    "@types/rn-fetch-blob": "^1.2.1",
    "@types/victory": "^0.9.13",
    "axios": "^0.17.1",
    "color": "^2.0.1",
    "core-js": "^2.5.1",
    "crypto-js": "^3.1.9-1",
    "cucumber": "^4.0.0",
    "cucumber-pretty": "^1.4.0",
    "d3-scale": "^1.0.5",
    "intl": "^1.2.5",
    "io-ts": "^1.8.2",
    "lodash": "^4.17.15",
    "lottie-react-native": "3.0.3",
    "moment": "^2.24.0",
    "react": "16.9.0",
    "react-intl": "^2.4.0",
    "react-native": "0.61.5",
    "react-native-add-calendar-event": "^3.0.1",
    "react-native-android-location-enabler": "1.0.8",
    "react-native-android-open-settings": "^1.3.0",
    "react-native-animatable": "^1.3.3",
    "react-native-calendar-events": "^1.7.3",
    "react-native-camera": "^3.23.1",
    "react-native-cookies": "^3.3.0",
    "react-native-dark-mode": "^0.2.2",
    "react-native-dash": "0.0.11",
    "react-native-device-info": "5.4.1",
    "react-native-exit-app": "^1.0.0",
    "react-native-fbsdk": "1.1.2",
    "react-native-firebase": "^5.5.6",
    "react-native-fs": "^2.13.3",
    "react-native-gesture-handler": "^1.6.1",
    "react-native-i18n": "^2.0.15",
    "react-native-keyboard-aware-scroll-view": "^0.9.1",
    "react-native-keychain": "^3.1.1",
    "react-native-maps": "^0.27.1",
    "react-native-maps-super-cluster": "^1.6.0",
    "react-native-pdf": "5.0.9",
    "react-native-permissions": "^1.0.6",
    "react-native-popover-view": "^2.1.3",
    "react-native-safari-view": "^2.1.0",
    "react-native-scroll-into-view": "^1.0.3",
    "react-native-share": "^3.1.1",
    "react-native-svg": "^9.5.1",
    "react-native-version-number": "^0.3.6",
    "react-native-video": "^4.3.1",
    "react-native-webview": "^7.5.2",
    "react-navigation": "3.11.1",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0",
    "rn-fetch-blob": "^0.10.16",
    "styled-components": "^4.4.1",
    "uuid": "^3.3.3",
    "victory-native": "^30.6.0"
  }

and pods

  pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
  pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
  pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
  pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
  pod 'React', :path => '../node_modules/react-native/'
  pod 'React-Core', :path => '../node_modules/react-native/'
  pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
  pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
  pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
  pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
  pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
  pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
  pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
  pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
  pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
  pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
  pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
  pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'

  pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
  pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
  pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
  pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
  pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
  pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
  pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

  pod 'Firebase/Core', '~> 6.20.0'
  pod 'Firebase/DynamicLinks', '~> 6.20.0'
  pod 'Firebase/Messaging', '~> 6.20.0'
  pod 'Firebase/Performance', '~> 6.20.0'

  # React Native Maps dependencies
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  pod 'GoogleMaps'
  pod 'Google-Maps-iOS-Utils'

@krzysztofnowak
Copy link

@MateusAndrade my config presented above

@MateusAndrade
Copy link
Collaborator

@krzysztofnowak did you try upgrading to a newer version of react-native and react-native-share?

@krzysztofnowak
Copy link

@MateusAndrade I made also test on totally empty, fresh project generated by react-native-cli with RN 0.63.2 and latest version of react-native-share. Same issue

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open

@github-actions github-actions bot added the stale There has been a lack of activity on this issue and it may be closed soon. label May 19, 2021
@arthedza
Copy link

Any updates?

@mikehardy
Copy link
Collaborator

Any updates?

@arthedza you're doing open source in a non-optimal way https://medium.com/hackernoon/i-thought-i-understood-open-source-i-was-wrong-cf54999c097b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted os: ios stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

7 participants