Search code examples
androidperformanceapisafetynet

Why is Google SafetyNet attestation taking 5+ seconds?


Just wondering if this is something anyone else has experienced. When I'm requesting a compatibility check, in my app it seems to take less than a second (~750ms). Unfortunately I also maintain a library that has been integrated by other applications, and they've complained that SafetyNet calls can take 5-10 seconds. I'm not sure why this would be any different. Could it be something unique about their app that's causing the same calls, in the same library, to take so long? Any tips or things to consider looking into when debugging this?


Solution

  • SafetyNet Attestation is a very complex check that includes lots of system checks, and eventually a call to Google servers to get your attestation result and its signature.

    Therefore, it is perfectly possible for an Attestation check to take a few seconds, especially on slow devices or slow networks.

    You should perform attestation asynchronously, and don't block the app's main thread while waiting for the result.