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

FIDO2 NetworkOnMainThreadException #79

Closed
ckgal opened this issue May 2, 2024 · 2 comments
Closed

FIDO2 NetworkOnMainThreadException #79

ckgal opened this issue May 2, 2024 · 2 comments

Comments

@ckgal
Copy link

ckgal commented May 2, 2024

I have downloaded the source code and tried to configure the fido2 to work with a fido2 server.
Managed to send registerRequest and got the response. While finish handling the response, the app crash with the below error.
I would like to check if the code works and also do i have to modify to use async instead?
I need to connect to physical key and hence yet to switch to Credential Manager.

2024-05-02 16:15:50.556 25176-25176 System.out com...oid.gms.identity.sample.fido2 I DEBUGGING: Skipped: extensions 2024-05-02 16:15:50.562 25176-25176 AuthRepository com...oid.gms.identity.sample.fido2 E Cannot call registerRequest android.os.NetworkOnMainThreadException at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1667) at com.android.org.conscrypt.Platform.blockGuardOnNetwork(Platform.java:436) at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.processDataFromSocket(ConscryptEngineSocket.java:874) at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.readUntilDataAvailable(ConscryptEngineSocket.java:862) at com.android.org.conscrypt.ConscryptEngineSocket$SSLInputStream.read(ConscryptEngineSocket.java:835) at okio.InputStreamSource.read(JvmOkio.kt:90) at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:129) at okio.RealBufferedSource.request(RealBufferedSource.kt:206) at okio.RealBufferedSource.require(RealBufferedSource.kt:199) at okio.RealBufferedSource.readHexadecimalUnsignedLong(RealBufferedSource.kt:381) at okhttp3.internal.http1.Http1ExchangeCodec$ChunkedSource.readChunkSize(Http1ExchangeCodec.kt:429) at okhttp3.internal.http1.Http1ExchangeCodec$ChunkedSource.read(Http1ExchangeCodec.kt:408) at okhttp3.internal.Util.skipAll(Util.kt:337) at okhttp3.internal.Util.discard(Util.kt:358) at okhttp3.internal.http1.Http1ExchangeCodec$ChunkedSource.close(Http1ExchangeCodec.kt:450) at okio.ForwardingSource.close(ForwardingSource.kt:34) at okhttp3.internal.connection.Exchange$ResponseBodySource.close(Exchange.kt:309) at okio.RealBufferedSource.close(RealBufferedSource.kt:477) at okio.RealBufferedSource$inputStream$1.close(RealBufferedSource.kt:170) at sun.nio.cs.StreamDecoder.implClose(StreamDecoder.java:423) at sun.nio.cs.StreamDecoder.close(StreamDecoder.java:196) at java.io.InputStreamReader.close(InputStreamReader.java:195) at java.io.BufferedReader.close(BufferedReader.java:539) i at android.util.JsonReader.close(JsonReader.java:540) at kotlin.io.CloseableKt.closeFinally(Closeable.kt:57) at com.google.android.gms.identity.sample.fido2.api.AuthApi.parsePublicKeyCredentialCreationOptions(AuthApi.kt:332) at com.google.android.gms.identity.sample.fido2.api.AuthApi.access$parsePublicKeyCredentialCreationOptions(AuthApi.kt:55) at com.google.android.gms.identity.sample.fido2.api.AuthApi$registerRequest$2.invoke(AuthApi.kt:165) at com.google.android.gms.identity.sample.fido2.api.AuthApi$registerRequest$2.invoke(AuthApi.kt:163) at com.google.android.gms.identity.sample.fido2.api.AuthApi.result(AuthApi.kt:620) at com.google.android.gms.identity.sample.fido2.api.AuthApi.registerRequest(AuthApi.kt:163) at com.google.android.gms.identity.sample.fido2.api.AuthApi$registerRequest$1.invokeSuspend(Unknown Source:15) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at android.os.Handler.handleCallback(Handler.java:942) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8762) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

@ckgal
Copy link
Author

ckgal commented May 8, 2024

For demo purpose, managed to make it work by adding this line in MainActivity.kt
// Disable StrictMode's network policy StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitNetwork().build())

@niharika2810
Copy link
Contributor

Thanks, would you mind creating a bug with all details required in that template if still the case? Sharing here : https://issuetracker.google.com/issues/new?component=1301097&template=1773864

Closing from here

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

No branches or pull requests

2 participants