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.

@getsantry getsantry bot removed the status in GitHub Issues with 👀 Dec 4, 2023
@philipphofmann philipphofmann moved this from Needs Discussion to Needs Investigation in Mobile & Cross Platform SDK Dec 6, 2023
@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 ?

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Dec 28, 2023
@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

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Dec 29, 2023
@philipphofmann philipphofmann self-assigned this Jan 3, 2024
@getsantry getsantry bot removed the status in GitHub Issues with 👀 2 Jan 4, 2024
@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

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Jan 15, 2024
@caspg
Copy link

caspg commented Apr 10, 2024

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

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Apr 10, 2024
@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

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 May 18, 2024
@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 philipphofmann moved this from Needs Investigation to Needs Discussion in Mobile & Cross Platform SDK Jun 13, 2024
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 philipphofmann moved this from Needs Discussion to Needs Review in Mobile & Cross Platform SDK Jun 17, 2024
@github-project-automation github-project-automation bot moved this from Needs Review to Done in Mobile & Cross Platform SDK Jun 17, 2024
@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