agilebits / onepassword-app-extension

1Password Extension for iOS Apps
2.58k stars 311 forks source link

Crash on iPad/iOS 10 when trying to open the extension in a form sheet #348

Closed lvandal closed 3 years ago

lvandal commented 7 years ago

This used to work properly on iOS 9 but will crash every single time on iOS 10. To reproduce the issue, simply run the attached project on an iPad.

2016-09-27 10:48:22.041843 Screens[2024:1164537] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIActivityViewController (<UIActivityViewController: 0x15de65630>). In its current trait environment, the modalPresentationStyle of a UIActivityViewController with this style is UIModalPresentationPopover. You must provide location information for this popover through the view controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the view controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'

OnePasswordCrash.zip

gks commented 7 years ago

Hi @lvandal

Thanks for taking the time to get in touch with the trouble you're having. After taking a look at this, I believe I've figured out where things went wrong in the project you provided. Thank you for providing that because it helped me track this down a lot easier.

The problem was that our API is expecting a UIView or UIBarButtonItem for sender, but you were passing self, which is an instance of UIViewController. This was the cause of the crash. To fix this, simply pass a valid sender, rather than a view controller. I went one step further and edited your sample project and turned the button into an outlet, passing that as the sender.

That said, I am leaving this issue open as I want to add an assert for the scenario you ran into to help better troubleshoot this in the future. I still need to do some testing before I create a pull request for this. Thanks for helping us track this down with a superb sample project. I wish everyone sent these in with their bug reports! :)

Let me know if that helps get things squared away for you.

lvandal commented 7 years ago

Thank you for the quick turnaround. That's odd that this was even working on previous iOS versions.

I've made the recommended changes and the crash is gone. Thanks again!

gks commented 7 years ago

@lvandal They must be checking things differently under the hood in iOS 10. But definitely interesting :)

Do let us know if you have any trouble in the future and thank you again for reporting it and even more thanks for sending the sample project! Have a great week!

gks commented 7 years ago

Hi @fbronner

I'm not totally sure I follow here. Code samples are excellent in these types of cases so if you can send those or a sample project it allows me to rework things or see where it might be going belly up.

But the big thing is that the action sheet is going to be brought up from a tap, typically from an onscreen UI item, which will be of type UIView or UIBarButtonItem. If you're trying to open it from somewhere else the easiest fix is going to be to fire it off from the action on the UI item instead. It's fairly simple code and for most apps is going to be a couple lines of code.

If you're doing something more complicated a sample to show how might be really useful so we can discuss with something a bit more close to real world usage.

fbronner commented 7 years ago

Hi,

I removed the comment when I saw I had simply not passed a uibutton as the sender. It was an UIImageView...

Doh!

Thanks for the prompt response

Kyle Swank wrote:

Hi @fbronner https://github.com/fbronner

I'm not totally sure I follow here. Code samples are excellent in these types of cases so if you can send those or a sample project it allows me to rework things or see where it might be going belly up.

But the big thing is that the action sheet is going to be brought up from a tap, typically from an onscreen UI item, which will be of type UIView or UIBarButtonItem. If you're trying to open it from somewhere else the easiest fix is going to be to fire it off from the action on the UI item instead. It's fairly simple code and for most apps is going to be a couple lines of code.

If you're doing something more complicated a sample to show how might be really useful so we can discuss with something a bit more close to real world usage.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/agilebits/onepassword-app-extension/issues/348#issuecomment-321043447,

or mute the thread https://github.com/notifications/unsubscribe-auth/AACvJbMCpO7J1msy3TbreBdfuVNdDcF6ks5sWKoOgaJpZM4KHxre.

gks commented 7 years ago

Hi @fbronner

Whoops :) I opened the page before you deleted the comment I guess. I'm glad you got it worked out though! Sorry for the trouble however. If I can ever assist in the future just reach out!

rudyrichter commented 3 years ago

In light of the retirement of this extension, I'm closing out any remaining issues and branches.