facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.19k stars 24.33k forks source link

iOS app crash when using Share API #33644

Closed arthedza closed 8 months ago

arthedza commented 2 years ago

Description

Trying to use Share API to share a pdf file in base64 format, the iOS app crashes after the share button is pressed. The share action sheet opens for a little moment and then immediately closed (first part of the log). If I try to open a share dialog again, the application crashes (first part of the log). The android app is working well. Tried also to share a simple string message -- the same result. Also the same issue with React Native Share

The app was bootstrapped via React Native Boilerplate The log gist Podfile

Version

0.66.2

Output of npx react-native info

System: OS: macOS 12.2.1 CPU: (8) x64 Apple M1 Memory: 31.48 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.3.1 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.3.0 - /usr/local/bin/npm Watchman: 2022.01.17.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/opt/ruby/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: API Levels: 29, 31, 32 Build Tools: 29.0.2, 29.0.3, 32.0.0 System Images: android-29 | Intel x86 Atom_64, android-31 | Google APIs ARM 64 v8a, android-32 | Google APIs ARM 64 v8a Android NDK: Not Found IDEs: Android Studio: 2021.1 AI-211.7628.21.2111.8193401 Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild Languages: Java: 11.0.11 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: ^0.66.2 => 0.66.2 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Use the Share API

Snack, code example, screenshot, or link to a repository

The log gist Podfile

"dependencies": {
    "@react-native-async-storage/async-storage": "^1.15.5",
    "@react-native-community/datetimepicker": "^5.1.0",
    "@react-native-community/masked-view": "^0.1.11",
    "@react-navigation/bottom-tabs": "^6.3.1",
    "@react-navigation/native": "^6.0.10",
    "@react-navigation/native-stack": "^6.6.1",
    "@reduxjs/toolkit": "^1.8.0",
    "@thecodingmachine/redux-toolkit-wrapper": "2.0.1",
    "axios": "^0.26.0",
    "fbjs": "^3.0.4",
    "formik": "^2.2.9",
    "i18next": "^20.3.2",
    "lodash": "^4.17.21",
    "moment": "^2.29.1",
    "prop-types": "^15.7.2",
    "re-reselect": "^4.0.0",
    "react": "17.0.2",
    "react-i18next": "^11.11.0",
    "react-native": "^0.66.2",
    "react-native-action-sheet": "^2.2.0",
    "react-native-color-matrix-image-filters": "^5.2.10",
    "react-native-confirmation-code-field": "^7.3.0",
    "react-native-currency-input": "^1.0.1",
    "react-native-device-info": "^8.4.8",
    "react-native-dotenv": "^3.3.1",
    "react-native-encrypted-storage": "^4.0.2",
    "react-native-flipper": "^0.136.0",
    "react-native-fs": "^2.19.0",
    "react-native-gesture-handler": "^2.3.0",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-reanimated": "^2.4.1",
    "react-native-safe-area-context": "3.4.1",
    "react-native-screens": "^3.13.1",
    "react-native-select-contact": "^1.6.3",
    "react-native-share": "^7.3.7",
    "react-native-svg": "^12.1.1",
    "react-redux": "^7.2.6",
    "redux": "^4.1.2",
    "redux-flipper": "^2.0.1",
    "redux-persist": "^6.0.0",
    "reselect": "^4.1.5",
    "yup": "^0.32.11"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "@babel/preset-env": "^7.1.6",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "@types/fbemitter": "^2.0.32",
    "@types/jest": "^27.0.1",
    "@types/lodash": "^4.14.178",
    "@types/react": "^17.0.21",
    "@types/react-native": "^0.65.0",
    "@types/react-native-dotenv": "^0.2.0",
    "@types/react-native-snap-carousel": "^3.8.5",
    "@types/react-redux": "^7.1.18",
    "@types/react-test-renderer": "^17.0.1",
    "@typescript-eslint/eslint-plugin": "^5.15.0",
    "@typescript-eslint/parser": "^5.15.0",
    "babel-jest": "^26.6.3",
    "babel-plugin-module-resolver": "^4.0.0",
    "eslint": "^8.11.0",
    "eslint-import-resolver-babel-module": "^5.1.2",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jest": "^26.1.1",
    "eslint-plugin-prettier": "^4.0.0",
    "generate-changelog": "^1.8.0",
    "husky": "^7.0.0",
    "identity-obj-proxy": "^3.0.0",
    "jest": "^26.6.3",
    "lint-staged": "^12.3.6",
    "metro-react-native-babel-preset": "^0.64.0",
    "prettier": "^2.5.1",
    "pretty-quick": "^3.1.3",
    "react-native-svg-transformer": "^1.0.0",
    "react-test-renderer": "^17.0.2",
    "typescript": "^4.4.3"
  },
hau1412 commented 2 years ago

Me too: React native version: 0.61.5

kendallroth commented 1 year ago

Can confirm that I am experiencing the first part of this, where the iOS Share dialog shows up but immediately goes away (no crash). Everything works as expected on Android...

andresrechimon commented 1 year ago

Can confirm that I am experiencing the first part of this, where the iOS Share dialog shows up but immediately goes away (no crash). Everything works as expected on Android...

I solved this by adding await before "share" function. Like this:

[...].then(async(result) => { await this.share({ title:bla, message:bla, filename:bla, url:bla })

"share" function, to be clear: share = async (customOptions: OptionsShare) => { try { await Share.open(customOptions); } catch (err) { console.log('share in balance', err); } };

Works on android and iOS. I hope it helps.

mrsubtle commented 1 year ago

Any updates to this Issue? Some additional context perhaps: in the iOS Simulator, the Share modal appears as expected when triggering the promise via async/await but in the final built app (via Expo SDK 45 through 48) the app crashes immediately.

Happy to provide any additional logs if anyone needs.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] commented 8 months ago

This issue was closed because it has been stalled for 7 days with no activity.