alinz / react-native-share-extension

react-native as an engine to drive share extension
MIT License
765 stars 401 forks source link

Crash when sharing from the iOS 11 screenshot editor. #47

Open bluey31 opened 7 years ago

bluey31 commented 7 years ago

The following project shows an example of a app that utilizes react-native-share-extension to the simplest level: https://github.com/bluey31/ShareTest11

When the share extension is triggered from Photos, for example, the share extension persists and can be interacted with. Although, when the share extension is triggered from the iOS 11 screenshot editor (that is presented in iOS 11 when a screenshot is taken) the share extension crashes due to thanks from the line const { type, value } = await ShareExtension.data() (#60 ShareTest11Ext.js).

I believe the way you harvest the photo is having trouble dealing with the fact the image is mid-edit...hope this helps.

Brendon

bluey31 commented 7 years ago

I think I have found the code in question within ReactNativeShareExtension.m. When extracting data from the extension context an error occurs along the pipeline returning the image. My suspicions are that it is because it exists in memory, and not in storage, but I may be wrong. Another possibility is that it is a special type of NSExtensionItem attachment that isn't being picked up.

(I have removed the URL and Text provider parsing so I could compact the code into one screenshot)

screen shot 2017-07-20 at 11 32 58
bluey31 commented 7 years ago

Maybe something like - loadDataRepresentationForTypeIdentifier:completionHandler: or - loadFileRepresentationForTypeIdentifier:completionHandler: needs to process the image instead?

bluey31 commented 7 years ago

Found the fix, PR created.

alinz commented 7 years ago

@bluey31 this is pretty good. Nice job. Look into it

bluey31 commented 7 years ago

I've re-opened the PR with a more thorough change, worth checking out.