react-native-share-menu icon indicating copy to clipboard operation
react-native-share-menu copied to clipboard

Crash when share from some apps. [iOS]

Open Shchepotin opened this issue 3 years ago • 16 comments

ShareExtension works fine is most cases, but when I try share url from some apps, for example Mango, ShareExtension crash.

I debug ShareExtension and get error in https://github.com/meedan/react-native-share-menu/blob/master/ios/ShareViewController.swift#L163.

I think it's happen because Mango app share few attachments (image, url) and ShareViewController return only first attachment (image). Can we return all (I think this is the right way) or first attachment which supported by app type identifiers? My app work only with URL and plain text and don't handle image.

Shchepotin avatar Mar 29 '21 13:03 Shchepotin

I'm facing this issue as well. Does anybody have solution for this?

mdmush avatar Apr 07 '21 10:04 mdmush

Same here...Has anyone found a solution? Happens for Twitter, LinkedIn, Reddit (and others) for me. Safari works fine.

At first I suspected that the max memory limit of an extension has been reached causing the extension to close automatically. Not too sure about that one though, also hard to debug...

In debug mode on a real device it always closes automatically (from any app, also from safari). In release mode it does not provide any information via Xcode.

yannikw23 avatar Apr 19 '21 10:04 yannikw23

Ok, I inspected the issue using the MacOS Console tool to get detailed device logs. This is the fatal error crashing the extension:

default 13:12:49.844917+0200 kernel EXC_RESOURCE -> <EXTENSION_NAME>[13182] exceeded mem limit: InactiveHard 120 MB (fatal)

This is a pain, as I don't know how to reduce the required memory...I use AWS Amplify and a couple of other frameworks which seem to be very memory intensive. And unfortunately I need them for my application.

@Gustash do you have any idea how to tackle this? Maybe reducing image size (I display a couple in my extension's custom view) would also help? Any help is highly appreciated!

yannikw23 avatar Apr 20 '21 11:04 yannikw23

Same problem.

I tried debbug with the XCode Profiler and found that the extension on the simulator consumes 3 times more memory than the main application. But there are much fewer components in it. On a real device, the situation is almost the same.

In my case it always falls (9 times out of 10) when I try share inside Soundcloud. Always memory issue on load

Sharisu avatar May 21 '21 20:05 Sharisu

@Sharisu I've been struggling with this for a while now and currently I am using a very hacky work around:

I created a MemoryWarningHandler component which is imported in my share extension. On memory warning it calls ShareMenu.continueInApp() to handle the sharing in there. That way at least the user has the chance to complete the sharing transaction.

const MemoryWarningHandler = (props: MemoryWarningProps) => {
  const { onMemoryWarningCallback } = props;

  useEffect(() => {
    // Listen for AppState memoryWarning event
    AppState.addEventListener('memoryWarning', (state) => {
      console.warn('Triggered memoryWarning. Initiating continueInApp');
      // call callback on warningEvent triggered
      onMemoryWarningCallback();
    });

    return () => {
      AppState.removeEventListener('memoryWarning', () => {});
    };
  }, []);

  return null;
};

This is very far from ideal, but it gets the job done (at the expense of user experience)... Maybe it helps you as well.

@Gustash Are there any updates on this? @caiosba maybe?

yannikw23 avatar May 31 '21 17:05 yannikw23

This is still an issue for us as well.

Strangely this is predominately affecting when sharing from Instagram app.

@Gustash have you been able to look into this at all? Thank you!

alexpluto avatar Jun 09 '21 08:06 alexpluto

@alexpluto Do you currently have a workaround for this issue?

yannikw23 avatar Jun 14 '21 08:06 yannikw23

@yannikw23 this workaround didn't work for us and we still have no other solutions... :(

alexpluto avatar Jun 14 '21 13:06 alexpluto

@yannikw23 nice trick! This made the situation better, but did not completely solve the problem. Thanks for idea :)

Sharisu avatar Jun 15 '21 11:06 Sharisu

@yannikw23 I have the same issue when I'm trying to share some data from Instagram app . ShareExtension is crashed immediately in most cases, adding "memoryWarning" listener doesn't solve my problem, the crash is still exist.

Kumskov-dev avatar Jun 16 '21 06:06 Kumskov-dev

@Sharisu - yeah, same here. It made the situation bearable, but definitely still far from ideal.

@Kumskov-dev I see. Yes, the crash still appears but we catch that in the main app then since we call continueInApp().

It's a bit frustrating...Is any of you sufficiently advanced in native dev to investigate this further?

Otherwise, can we hope for support? @Gustash (sorry to keep bringing it up, it's just a major hurdle)

yannikw23 avatar Jun 17 '21 10:06 yannikw23

Or maybe @caiosba (seems like another big contributor here). Any help would be super helpful guys! Thank you in advance.

alexpluto avatar Jun 17 '21 17:06 alexpluto

I just maintain the Android version... @Gustash do you have any chance to look into it?

We accept PRs from the community too, if anyone is able to fix it.

caiosba avatar Jun 17 '21 19:06 caiosba

@Gustash I was just wondering if you ever managed to look at this issue? It's still affecting us now unfortunately :(

alexpluto avatar Aug 17 '21 10:08 alexpluto

Got the same issue, for example in ios gmail app, opening a url inside the gmail app (not in the browser), and trying to share the url using share menu crashes the share modal. I see the following in xcode. Screenshot 2021-12-15 at 12 10 07

eranga-akva avatar Dec 15 '21 06:12 eranga-akva

I think all this is related to how the default share popup is displayed to the user. See this #256

I was having the same issues with some apps, I realized is related with how the preview content is displayed.

RDR96 avatar Jul 14 '23 03:07 RDR96