Skip to content

Crash: Fragment State loss exception #614

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

Closed
maskaravivek opened this issue May 16, 2017 · 0 comments
Closed

Crash: Fragment State loss exception #614

maskaravivek opened this issue May 16, 2017 · 0 comments

Comments

@maskaravivek
Copy link
Member

maskaravivek commented May 16, 2017

The app is crashing as we are trying to commit the fragment onPostExecute call of an AsyncTask but theres a possibility that the onSaveInstanceState has already been called for it. Here's a blog post explaining why this happens.

FATAL EXCEPTION: main Process: fr.free.nrw.commons, PID: 10644
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
 at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1842)
 at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1860)
 at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:649)
 at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:609)
 at fr.free.nrw.commons.nearby.NearbyActivity.setListFragment(NearbyActivity.java:247)
 at fr.free.nrw.commons.nearby.NearbyActivity$NearbyAsyncTask.onPostExecute(NearbyActivity.java:219)
 at fr.free.nrw.commons.nearby.NearbyActivity$NearbyAsyncTask.onPostExecute(NearbyActivity.java:166)
 at android.os.AsyncTask.finish(AsyncTask.java:651)
 at android.os.AsyncTask.-wrap1(AsyncTask.java)
 at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:668)
 at android.os.Handler.dispatchMessage(Handler.java:102)
 at android.os.Looper.loop(Looper.java:148)
 at android.app.ActivityThread.main(ActivityThread.java:5417)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

The issue is similar to #435 but its because of a different code path. And the fix in this case would be different as described in the blog post.

maskaravivek pushed a commit to maskaravivek/apps-android-commons that referenced this issue May 19, 2017
misaochan added a commit that referenced this issue May 19, 2017
Fixes #614: Crash: Fragment State loss exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant