Fixed
Status Update
Comments
kc...@google.com <kc...@google.com>
cu...@google.com <cu...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit c46d3e79b2ea8b839358f0215b0a432ef8fad7a2
Author: Clara Fok <clarafok@google.com>
Date: Fri Nov 04 15:23:25 2022
Convert androidx.activity.Cancellable to kotlin
Test: ./gradlew activity:activity:cC
Bug: 257291701
Change-Id: I057f3e54811e7399e40083ef5e3915adc4fa425d
M activity/activity/src/main/java/androidx/activity/Cancellable.kt
https://android-review.googlesource.com/2288554
Branch: androidx-main
commit c46d3e79b2ea8b839358f0215b0a432ef8fad7a2
Author: Clara Fok <clarafok@google.com>
Date: Fri Nov 04 15:23:25 2022
Convert androidx.activity.Cancellable to kotlin
Test: ./gradlew activity:activity:cC
Bug: 257291701
Change-Id: I057f3e54811e7399e40083ef5e3915adc4fa425d
M activity/activity/src/main/java/androidx/activity/Cancellable.kt
Description
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManagerImpl.checkStateLoss(FragmentManagerImpl.java:1534)
at androidx.fragment.app.FragmentManagerImpl.enqueueAction(FragmentManagerImpl.java:1556)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:591)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:543)
at androidx.fragment.app.DialogFragment.dismissInternal(DialogFragment.java:250)
at androidx.fragment.app.DialogFragment.dismiss(DialogFragment.java:202)
at androidx.biometric.FingerprintDialogFragment$2.run(FingerprintDialogFragment.java:360)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:180)
at android.app.ActivityThread.main(ActivityThread.java:6950)
at java.lang.reflect.Method.invoke(Method.java:-2)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:835)
I would argue that the library should be using the method dismissAllowingStateLoss to dismiss it's dialog because:
1) There is no way for the library implementers to stop this from crashing, even if they call cancelAuthentication() on the biometrics prompt onPause() this error will still happen
2) There is no actual state in the biometrics library that needs to be saved
3) Since this is dismissed with a delay there is no way to guarantee the activity will always be in a good state when it's cleaned up. If the activity gets stopped between the error and the postDelayed there will be a crash
4) A common use case for biometrics is to prevent a user from using the app until they have passed the prompt. This means they will want to have a generic place to launch the biometrics prompt making it very hard to guarantee it's always safe to dismiss the dialog
It's tricky to reproduce so I didn't provide a sample project but it is crashing in our production app. I can probably create one if you still think it's necessary
BUILD INFO
- Device type: SM-G570M, SM-G930F, SM-G930U, ASUS_X00DDB, CPH1819, HTC U11, LG-Q710AL, SM-C710F, SM-C710F, SNE-LX1
- OS version: 8.0.0 and 8.1.0
- Biometric library version: 1.0.0-alpha04
STEPS TO REPRODUCE
If the activity has had onStop called on it before the postDelayed is triggered it will throw an IllegalStateException.
EXPECTED RESULTS
No crash should occur in the library
OBSERVED RESULTS
A crash occurs
NUMBER OF TIMES YOU WERE ABLE TO REPRODUCE
I haven't reproduced it myself but it seems to be pretty regularly occurring in our production app.