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

Getting error in Flutter Share only on iPad #44962

Closed
saeedjassani opened this issue Nov 15, 2019 · 12 comments
Closed

Getting error in Flutter Share only on iPad #44962

saeedjassani opened this issue Nov 15, 2019 · 12 comments
Labels
e: device-specific Only manifests on certain devices p: share The Share plugin package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically

Comments

@saeedjassani
Copy link

When using the Share plugin on iPad, I am getting the following error:

    "<ShareData: 0x60000091e620>"
)
        Probably at least one of the constraints in the following list is one you don't want.
        Try this:
                (1) look at each constraint and try to figure out which you don't expect;
                (2) find the code that added the unwanted constraint or constraints and fix it.
(
    "<NSLayoutConstraint:0x600002a935c0 LPLinkView:0x7fbcd8e1e970.leading == UILayoutGuide:0x600003010700'UIViewLayoutMarginsGuide'.leading   (active)>",
    "<NSLayoutConstraint:0x600002a926c0 H:[LPLinkView:0x7fbcd8e1e970]-(59)-|   (active, names: '|':_UIActivityContentTitleView:0x7fbcd66fa360 )>",
    "<NSLayoutConstraint:0x600002a868f0 H:|-(0)-[_UIActivityContentTitleView:0x7fbcd66fa360]   (active, names: '|':_UINavigationBarContentView:0x7fbcd8e20880 )>",
    "<NSLayoutConstraint:0x600002a86b70 _UIActivityContentTitleView:0x7fbcd66fa360.trailing == _UINavigationBarContentView:0x7fbcd8e20880.trailing   (active)>",
    "<NSLayoutConstraint:0x600002a87110 'UIView-Encapsulated-Layout-Width' _UINavigationBarContentView:0x7fbcd8e20880.width == 0   (active)>",
    "<NSLayoutConstraint:0x600002a93de0 'UIView-leftMargin-guide-constraint' H:|-(16)-[UILayoutGuide:0x600003010700'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UIActivityContentTitleView:0x7fbcd66fa360 )>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x600002a935c0 LPLinkView:0x7fbcd8e1e970.leading == UILayoutGuide:0x600003010700'UIViewLayoutMarginsGuide'.leading   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

Sharing functionality is working fine in Android as well as iPhones. Getting the above error in iPad only.

Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.10.17-pre.77, on Mac OS X 10.15.1 19B88, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.29.1)
[✓] Connected device (1 available)

• No issues found!

Any help will be greatly appreciated, thanks!

@iapicca
Copy link
Contributor

iapicca commented Nov 15, 2019

Hi @saeedjassani
could you please provide a minimal code sample to reproduce the problem
Thank you

@iapicca iapicca added p: first party p: share The Share plugin waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Nov 15, 2019
@saeedjassani
Copy link
Author

Code to reproduce:

Share.share('check out my website https://example.com');

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Nov 15, 2019
@agreensh
Copy link

agreensh commented Nov 17, 2019

Looking at the code for the share plugin, I see this

if (!CGRectIsEmpty(origin)) { activityViewController.popoverPresentationController.sourceRect = origin; }

so unless the caller supplies a 'sharePositionOrigin' rect, this will fail on an iPad (as on iPad the 'popoverPresentationController.sourceRect' has to be supplied), so its a bug in the plugin.

Simple workaround would be to pass in a (non-empty, so has width and height) sharePositionOrigin' rect in the Share.share(...) function (but needs the plugin updated to supply a default rect on iPad if no rect supplied - so check if userInterfaceIdiom == UIUserInterfaceIdiomPad - perhaps positioned bottom centre).

@saeedjassani
Copy link
Author

Thanks for you comment @agreensh . I don't have any experience of iOS development. Can you suggest any work-around for me which which help me solve the issue?

@agreensh
Copy link

Thanks for you comment @agreensh . I don't have any experience of iOS development. Can you suggest any work-around for me which which help me solve the issue?

I have... in your Dart code, pass the sharePositionOrigin parameter with non-zero rect to Share.share(...).

@sensuikan1973
Copy link
Contributor

sensuikan1973 commented Nov 18, 2019

I have the same problem.

Cause

https://github.com/flutter/plugins/blob/8380988745e4bfe6c8d547272b4fe1c3193514be/packages/share/ios/Classes/SharePlugin.m#L102-L105

  if (!CGRectIsEmpty(origin)) {
    activityViewController.popoverPresentationController.sourceRect = origin;
  }
  [controller presentViewController:activityViewController animated:YES completion:nil];

In iPad, ActionSheet always shows as popover.
So, if I do not pass sharePositionOrigin, this error occurs. i think.

Workaround

I expressly pass sharePositionOrigin like this.

await Share.share(
  'foo',
  sharePositionOrigin: Rect.fromCenter(center: Offset(100, 100), width: 100, height: 100),
)

if I attatch workaround to only iPad, use deviceinfo plugin. like this.

Future<bool> _isIpad() async {
  final iosInfo = await DeviceInfoPlugin().iosInfo;
  return iosInfo.name.toLowerCase().contains('ipad');
}

But this behavior is not ideal...

@bowenchin
Copy link

I am facing the same issues too. The share sheet refuses to pop up on iPad, but works fine on iPhone.

@agreensh
Copy link

Have you used the workaround?

@bowenchin
Copy link

Yes I have used the workaround and now the Share sheet shows up on the iPad, however, it's not an ideal long term solution.

@iapicca iapicca added e: device-specific Only manifests on certain devices platform-ios iOS applications specifically labels Jan 1, 2020
@karmazinkd
Copy link

karmazinkd commented Mar 4, 2020

I have the same problem.

Cause

https://github.com/flutter/plugins/blob/8380988745e4bfe6c8d547272b4fe1c3193514be/packages/share/ios/Classes/SharePlugin.m#L102-L105

  if (!CGRectIsEmpty(origin)) {
    activityViewController.popoverPresentationController.sourceRect = origin;
  }
  [controller presentViewController:activityViewController animated:YES completion:nil];

In iPad, ActionSheet always shows as popover.
So, if I do not pass sharePositionOrigin, this error occurs. i think.

Workaround

I expressly pass sharePositionOrigin like this.

await Share.share(
  'foo',
  sharePositionOrigin: Rect.fromCenter(center: Offset(100, 100), width: 100, height: 100),
)

if I attatch workaround to only iPad, use deviceinfo plugin. like this.

Future<bool> _isIpad() async {
  final iosInfo = await DeviceInfoPlugin().iosInfo;
  return iosInfo.name.toLowerCase().contains('ipad');
}

But this behavior is not ideal...

Thank you. With this workaround, it doesn't crash which is great.
But here is one thing: it shows this pop-up dialog.
image

and when you tap on 'Edit Actions...' it throws the same exception in the log (doesn't crash though):

Probably at least one of the constraints in the following list is one you don't want. 
	Try this: 
		(1) look at each constraint and try to figure out which you don't expect; 
		(2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x600002e16e40 V:|-(15)-[UILabel:0x7fb9c0443b40]   (active, names: '|':UITableViewCellContentView:0x7fb9c04437e0 )>",
    "<NSLayoutConstraint:0x600002e17840 V:[UILabel:0x7fb9c0443b40]-(15)-|   (active, names: '|':UITableViewCellContentView:0x7fb9c04437e0 )>",
    "<NSLayoutConstraint:0x600002e14870 UILabel:0x7fb9c0443b40.height >= 22   (active)>",
    "<NSLayoutConstraint:0x600002e276b0 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fb9c04437e0.height == 44   (active)>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x600002e14870 UILabel:0x7fb9c0443b40.height >= 22   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

XCode 11.3.1
iPad Pro (3-gen) simulator.
iOS 13.3

@iapicca
Copy link
Contributor

iapicca commented Mar 11, 2020

Hi @saeedjassani
I see there's an open issue addressing the case you described.
Please follow up on that issue,
I'm closing the current one as duplicate.
If you disagree please write in the comments
and I will reopen it.
Thank you

@lock
Copy link

lock bot commented Apr 4, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@lock lock bot locked and limited conversation to collaborators Apr 4, 2020
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
e: device-specific Only manifests on certain devices p: share The Share plugin package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically
Projects
None yet
Development

No branches or pull requests

6 participants