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

is It expected to sent App Hangs event if System popup about FaceId permission shown ? #3472

Closed
expcapitaldev opened this issue Dec 1, 2023 · 21 comments · Fixed by #4077
Closed

Comments

@expcapitaldev
Copy link

expcapitaldev commented Dec 1, 2023

Platform

iOS

Environment

Develop

Installed

Carthage

Version

8.13.1

Did it work on previous versions?

No response

Steps to Reproduce

Show System Popup with Access to Face Id after Secret.load

func loadSecret(_ command: CDVInvokedUrlCommand) {
    let data  = command.arguments[0] as AnyObject?;
    var prompt = "Authentication"
    if let description = data?.object(forKey: "description") as! String? {
        prompt = description;
    }
    var pluginResult: CDVPluginResult
    do {
        **let result = try Secret().load(prompt)**
        pluginResult = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: result);
    } catch {
        var code = PluginError.BIOMETRIC_UNKNOWN_ERROR.rawValue
        var message = error.localizedDescription
        if let err = error as? KeychainError {
            code = err.pluginError.rawValue
            message = err.localizedDescription
        }
        let errorResult = ["code": code, "message": message] as [String : Any]
        // ...
    }
}

Expected Result

no ANR App Hangs event

Actual Result

App Hanging

Secret.load

Are you willing to submit a PR?

No response

@brustolin
Copy link
Contributor

Hello @expcapitaldev thanks for reaching out.
I agree that this is not the desired behaviour, we need to investigate whether its possible to detect this system events to avoid reporting app hangs.

@kahest kahest self-assigned this Dec 6, 2023
@kahest
Copy link
Member

kahest commented Dec 13, 2023

The system notifications for iPhone Pro with dynamic island are not causing the app to hang according to our preliminary tests. We'll test other models without dynamic island next.

@expcapitaldev
Copy link
Author

hi guys, any updates here ?

@brustolin
Copy link
Contributor

Unfortunately we could not reproduce this yet @expcapitaldev
If you have any suggestion to help us out we appreciate.

@expcapitaldev
Copy link
Author

Show System Popup with Access to Face Id after Secret.load
So, you need only open that System Popup about access to FaceId, I will try later send screenshots, but please show it and see

@julianD77
Copy link

julianD77 commented Jan 15, 2024

We noticed our App started receiving instances of these errors for our live users after we recently updated the @sentry/react-native plugin from 4.15.0 to 5.9.1. The same issues still occurs when using 5.15.2. Our react-native version if useful is 0.72.9

When looking into the cause we then found this issue, alongside some similar posts:

#2715
react-native-clipboard/clipboard#212
flutter/flutter#133557 (comment)

We have been able to confirm that calls to Clipboard.getString and Clipboard.getStrings are resulting in "App hanging for at least ..." errors being reported to Sentry.

We have confirmed this using a specific test build which makes calls to the Clipboard method(s) Clipboard.getString(s). These methods can cause (see below) the iOS UIPasteboard permissions prompt to appear and will cause the SentryANRTracker to report an ANR and an "App hanging" error to be reported in Sentry.

NOTE that in order for the iOS System Privacy prompt to appear you may need to do the following:

  • Settings/General/Transfer & Reset/Reset/Reset Location & Privacy
  • Reboot the device
  • Delete & Reinstall the iOS test App being used to trigger the privacy prompt
  • Use a Release build of the test App

@philipphofmann
Copy link
Member

Thanks for the detailed info, @julianD77.

@SrAdam
Copy link

SrAdam commented Feb 8, 2024

Dear Sentry Team,
It is not specific to FaceId permission, but to any kind of permissions, for example copying from clipboard from a macOS device to an iOS device.
This issue results in a pletora of app hanging issues in my app.
Please fix the issue as it is already 2 months old and it keeps eating up my error quota again and again.
Thank you!

@philipphofmann
Copy link
Member

I tried to reproduce the issue but wasn't able to. I tried push notification permission, location permission, and a biometric prompt in our iOS-Swift sample app, see

@objc func requestBiometricPermission() {
let context = LAContext()
var error: NSError?
if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) {
let reason = "Identify yourself!"
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { success, _ in
DispatchQueue.main.async {
if success {
let crumb = Breadcrumb()
crumb.message = "Biometry success"
SentrySDK.addBreadcrumb(crumb)
} else {
let crumb = Breadcrumb()
crumb.message = "Biometry failure"
SentrySDK.addBreadcrumb(crumb)
}
}
}
} else {
let ac = UIAlertController(title: "No biometry", message: "Couldn't access biometry.", preferredStyle: .alert)
ac.addAction(UIAlertAction(title: "OK", style: .default))
self.present(ac, animated: true)
}
}
}

I also tried all of these with a TestFlight build, but none of these triggered an ANR.

@SrAdam, for which type of app do you experience the issue? A native iOS app? If yes, does it use SwiftUI or UIViewControllers? Do you build your app with React-Native or Flutter?

@expcapitaldev, when looking at your code snippet you posted above, I assume you use Cordova? Is that correct? If yes, doest this only happen with Cordova, or does it also happen when interacting with native iOS code?

@SrAdam
Copy link

SrAdam commented Feb 9, 2024

Thank you Philipp for the quick answer, and let me say sorry for not being explicit enough.

I am running a flutter app. My app was last updated 20 days ago, accordingly my versions:

Pubspec.lock:

dependencies:
  sentry_flutter: ^7.14.0
sdks:
  dart: ">=3.2.0 <4.0.0"
  flutter: ">=3.16.0"

Podfile.lock:

  - Sentry/HybridSDK (8.17.2):
    - SentryPrivate (= 8.17.2)
  - sentry_flutter (0.0.1):
    - Flutter
    - FlutterMacOS
    - Sentry/HybridSDK (= 8.17.2)
  - SentryPrivate (8.17.2)

Let me know if this is not the right channel for this issue and if that is the case, i would appreciate if you could point me out where to get further help.
Thanks again for your support!

@expcapitaldev
Copy link
Author

Thank you Philipp for answer, now I very very busy and will try to answer later for all questions and provide more code and information about case

@caspg
Copy link

caspg commented Apr 10, 2024

How do you deal with this in the meantime? Setting enableAppHangTracking to false?

@expcapitaldev
Copy link
Author

I use enableAppHangTracking: false,

@kjxbyz
Copy link

kjxbyz commented May 18, 2024

same issue

2024-05-19 07 08 41 2024-05-19 07 08 52

@philipphofmann
Copy link
Member

Thanks for the update, @kjxbyz.

@philipphofmann philipphofmann removed their assignment May 22, 2024
@philipphofmann philipphofmann self-assigned this Jun 12, 2024
@philipphofmann
Copy link
Member

I can reproduce the problem by simply calling in our iOS-Swift sample app.

if let clipboard = UIPasteboard.general.string {

}

When the following dialog appears, the Cocoa SDK wrongly detects an app hang. So this has nothing to do with React-Native or Flutter.
CleanShot 2024-06-13 at 15 01 49@2x

@brustolin, I tried to figure out how we can detect such dialogs. Watching the willResignActiveNotification and didBecomeActiveNotificationName doesn't work. I also played around with the FramesTracker to check if the CADisplayLink's properties timestamp, targetTimestamp, duration, or paused give away any useful information to know if a permission dialog is opened, but sadly, these properties all behave exactly the same as when I press the ANR fully blocking button. Do you maybe have any ideas?

@brustolin
Copy link
Contributor

Good thing we can reproduce it now.

Unfortunately I dont think there is an automatic solution for this, since Apple doesn't provide any API to report a system dialog being presented.

Some alternatives:

  • Swizzle all potencial blocking functions (Clipboard, TouchId/FaceId, Location)
  • Provide an automatic API that should be called before using one of those system functions.
SentrySDK.pauseAppHangTracking {
	//call clipboard in here
}

or

SentrySDK.pauseAppHangTracking()
//call clipboard in here
SentrySDK.resumeAppHangTracking()

Not a friendly solution but this is Apples fault, nothing we can do about it.

@philipphofmann
Copy link
Member

We could start with the pauseAppHangTracking callbacks for now, but they are also suboptimal cause most people have to learn it the hard way they have to use them. I don't really want to swizzle the blocking functions.

philipphofmann added a commit that referenced this issue Jun 17, 2024
Add two methods pauseAppHangTracking and
resumeAppHangTracking to ignore reported AppHangs.

Fixes GH-3472
philipphofmann added a commit that referenced this issue Jun 17, 2024
Add two methods pauseAppHangTracking and
resumeAppHangTracking to ignore reported AppHangs.

Fixes GH-3472
@philipphofmann
Copy link
Member

In the upcoming release, you can use the following API to ignore the app hangs. We're going to add these APIs also to Flutter and RN.

SentrySDK.pauseAppHangTracking()
// Do something that might cause the app to hang,
// and you don't want the Cocoa SDK to report it.
SentrySDK.resumeAppHangTracking()

@expcapitaldev
Copy link
Author

thanks!

@philipphofmann
Copy link
Member

Meta team SDK issue for reference: getsentry/team-mobile#186.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

9 participants