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

IllegalStateException: Can not perform this action after onSaveInstanceState #74

Closed
FrantisekGazo opened this issue Aug 30, 2021 · 7 comments
Assignees
Milestone

Comments

@FrantisekGazo
Copy link

I found multiple exceptions like this coming from the crisp sdk.

crisp sdk version: 1.0.7

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1691)
    at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1731)
    at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:321)
    at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:286)
    at androidx.fragment.app.DialogFragment.dismissInternal(DialogFragment.java:276)
    at androidx.fragment.app.DialogFragment.dismiss(DialogFragment.java:228)
    at im.crisp.client.b.e.b.a.b
    at im.crisp.client.b.e.b.a.f
    at im.crisp.client.b.e.b.a$a.i
    at im.crisp.client.b.e.b.a$a.lambda$q0csS3PiIawpr6l4W4Ieecax0Lw
    at im.crisp.client.b.e.b.-$$Lambda$a$a$q0csS3PiIawpr6l4W4Ieecax0Lw.run(lambda)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6121)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
@eliottvincent
Copy link
Member

Thanks! We'll check what's causing those exceptions.

@nasikhunamin
Copy link

I have same issue!

@Doc1faux
Copy link
Collaborator

I @FrantisekGazo & @nasikhunamin and thank you for your feedbacks.
This crash has been fixed in 1.0.9.
I let you reopen this issue if it happens again.

@FrantisekGazo
Copy link
Author

@Doc1faux it's still happening. Currently on version 1.0.10. Please reopen this issue.

java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    at androidx.fragment.app.FragmentManager.p(FragmentManager.java:2)
    at androidx.fragment.app.FragmentManager.Z(FragmentManager.java:5)
    at f.m.d.a.s(BackStackRecord.java:12)
    at f.m.d.a.h(BackStackRecord.java:1)
    at f.m.d.d.show(DialogFragment.java:5)
    at im.crisp.client.internal.t.a.a
    at im.crisp.client.internal.t.a.a
    at im.crisp.client.internal.t.a$a.b
    at im.crisp.client.internal.t.a$a.m
    at i.a.a.b.j.e.run(lambda)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6121)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

@Doc1faux
Copy link
Collaborator

Hi @FrantisekGazo and thank you for your feedback.

I firstly looked over your stacktrace but found nothing which could give me a hint on why this could happen because I've already protected all UI calls from async with isAdded() methods...
But while looking for "State loss exceptions", I found an old interesting blog post about it: https://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html
After reading this, I protected more these calls with the following pattern:

if (isAdded()) {
    FragmentManager manager = getParentFragmentManager() | getChildFragmentManager();
    if (! manager.isStateSaved()) {
        // perform fragment transaction
    }
}

I hope it will fix definitively these crashes...
I plan it for the next release.

@Doc1faux
Copy link
Collaborator

@FrantisekGazo 1.0.13 fixing this issue has just been released.
It can take a few hours before it will be available.
I close the issue.

@FrantisekGazo
Copy link
Author

thank you, will try

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

No branches or pull requests

4 participants