Skip to content

Conversation

@tomtargosz
Copy link
Contributor

Summary

Currently on iOS 13 the app will crash if you:

  • Open the share sheet
  • Tap something like messages or photos
  • Cancel the dialog
  • Perform any other action

This is because shareController.completionWithItemsHandler is called when the dialog box is canceled and currently failureCallback or successCallback will always be called. In the situation above, activityError is nil so successCallback will be called even though completed is false. This leaves us in a state where the callback has been invoked but the ShareSheet is still active, meaning the success or error callback will be invoked again, leading to the crash.

This PR adds a check to make sure completed is true before calling successCallback. This way successCallback will only be called when the user has successfully completed an action and the ShareSheet is closed.

Changelog

[iOS] [Fixed] - Fix crash in RCTActionSheetManager.m on iOS 13

Test Plan

  • Saved an image successfully
  • Opened and dismissed the Photos dialog multiple times without crashing

@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 13, 2019
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@PeteTheHeat
Copy link
Contributor

Awesome, thanks for the fix :)

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PeteTheHeat is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @tomtargosz in a4fbb8e.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added the Merged This PR has been merged. label Sep 13, 2019
tsapeta pushed a commit to expo/react-native that referenced this pull request Sep 13, 2019
Summary:
Currently on iOS 13 the app will crash if you:
- Open the share sheet
- Tap something like messages or photos
- Cancel the dialog
- Perform any other action

This is because `shareController.completionWithItemsHandler` is called when the dialog box is canceled and currently `failureCallback` or `successCallback` will always be called. In the situation above, `activityError` is `nil` so `successCallback` will be called even though `completed` is false. This leaves us in a state where the callback has been invoked but the ShareSheet is still active, meaning the success or error callback will be invoked again, leading to the crash.

This PR adds a check to make sure `completed` is true before calling `successCallback`. This way `successCallback` will only be called when the user has successfully completed an action and the ShareSheet is closed.

## Changelog

[iOS] [Fixed] - Fix crash in RCTActionSheetManager.m on iOS 13
Pull Request resolved: facebook#26429

Test Plan:
- Saved an image successfully
- Opened and dismissed the `Photos` dialog multiple times without crashing

Differential Revision: D17369712

Pulled By: PeteTheHeat

fbshipit-source-id: 228b696243cd39fad1fa134f4412d95d845b1bc5
esamelson pushed a commit to expo/react-native that referenced this pull request Sep 20, 2019
* Delete fishhook
* Fix ShareSheet crash on iOS 13 (facebook#26429)
ide pushed a commit to expo/react-native that referenced this pull request Sep 24, 2019
Summary:
Currently on iOS 13 the app will crash if you:
- Open the share sheet
- Tap something like messages or photos
- Cancel the dialog
- Perform any other action

This is because `shareController.completionWithItemsHandler` is called when the dialog box is canceled and currently `failureCallback` or `successCallback` will always be called. In the situation above, `activityError` is `nil` so `successCallback` will be called even though `completed` is false. This leaves us in a state where the callback has been invoked but the ShareSheet is still active, meaning the success or error callback will be invoked again, leading to the crash.

This PR adds a check to make sure `completed` is true before calling `successCallback`. This way `successCallback` will only be called when the user has successfully completed an action and the ShareSheet is closed.

## Changelog

[iOS] [Fixed] - Fix crash in RCTActionSheetManager.m on iOS 13
Pull Request resolved: facebook#26429

Test Plan:
- Saved an image successfully
- Opened and dismissed the `Photos` dialog multiple times without crashing

Differential Revision: D17369712

Pulled By: PeteTheHeat

fbshipit-source-id: 228b696243cd39fad1fa134f4412d95d845b1bc5
ide pushed a commit to expo/react-native that referenced this pull request Sep 24, 2019
Summary:
Currently on iOS 13 the app will crash if you:
- Open the share sheet
- Tap something like messages or photos
- Cancel the dialog
- Perform any other action

This is because `shareController.completionWithItemsHandler` is called when the dialog box is canceled and currently `failureCallback` or `successCallback` will always be called. In the situation above, `activityError` is `nil` so `successCallback` will be called even though `completed` is false. This leaves us in a state where the callback has been invoked but the ShareSheet is still active, meaning the success or error callback will be invoked again, leading to the crash.

This PR adds a check to make sure `completed` is true before calling `successCallback`. This way `successCallback` will only be called when the user has successfully completed an action and the ShareSheet is closed.

## Changelog

[iOS] [Fixed] - Fix crash in RCTActionSheetManager.m on iOS 13
Pull Request resolved: facebook#26429

Test Plan:
- Saved an image successfully
- Opened and dismissed the `Photos` dialog multiple times without crashing

Differential Revision: D17369712

Pulled By: PeteTheHeat

fbshipit-source-id: 228b696243cd39fad1fa134f4412d95d845b1bc5
grabbou pushed a commit that referenced this pull request Sep 25, 2019
Summary:
Currently on iOS 13 the app will crash if you:
- Open the share sheet
- Tap something like messages or photos
- Cancel the dialog
- Perform any other action

This is because `shareController.completionWithItemsHandler` is called when the dialog box is canceled and currently `failureCallback` or `successCallback` will always be called. In the situation above, `activityError` is `nil` so `successCallback` will be called even though `completed` is false. This leaves us in a state where the callback has been invoked but the ShareSheet is still active, meaning the success or error callback will be invoked again, leading to the crash.

This PR adds a check to make sure `completed` is true before calling `successCallback`. This way `successCallback` will only be called when the user has successfully completed an action and the ShareSheet is closed.

## Changelog

[iOS] [Fixed] - Fix crash in RCTActionSheetManager.m on iOS 13
Pull Request resolved: #26429

Test Plan:
- Saved an image successfully
- Opened and dismissed the `Photos` dialog multiple times without crashing

Differential Revision: D17369712

Pulled By: PeteTheHeat

fbshipit-source-id: 228b696243cd39fad1fa134f4412d95d845b1bc5
duypham-evizi pushed a commit to duypham-evizi/react-native that referenced this pull request Oct 17, 2019
* Delete fishhook
* Fix ShareSheet crash on iOS 13 (facebook#26429)

(cherry picked from commit 57e23b8)
jdanbrown added a commit to jdanbrown/birdgram that referenced this pull request Oct 28, 2019
- facebook/react-native#26429
- Occurred during upgrade: ios 12 -> 13 (with xcode 10 -> 11)
- Safe to XXX after react-native 0.61.1 (currently 0.57.2)
jdanbrown added a commit to jdanbrown/birdgram that referenced this pull request Jan 4, 2020
- facebook/react-native#26429
- Occurred during upgrade: ios 12 -> 13 (with xcode 10 -> 11)
- Safe to XXX after react-native 0.61.1 (currently 0.57.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API: Share Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. Platform: iOS iOS applications.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants