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

Fragment MainFragment{fb222c4} is not currently in the FragmentManager on install #1555

Open
EmmanuelMess opened this issue Dec 28, 2018 · 4 comments · May be fixed by #3923
Open

Fragment MainFragment{fb222c4} is not currently in the FragmentManager on install #1555

EmmanuelMess opened this issue Dec 28, 2018 · 4 comments · May be fixed by #3923
Labels
Area-UIUX Related to user interface/experience (e.g. dialogs, notifications). Issue-Bug Related unexpected behavior or something worth investigating.
Milestone

Comments

@EmmanuelMess
Copy link
Member

12-28 14:22:12.244 com.amaze.filemanager.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.amaze.filemanager.debug, PID: 17898
    java.lang.IllegalStateException: Fragment MainFragment{fb222c4} is not currently in the FragmentManager
        at android.support.v4.app.FragmentManagerImpl.putFragment(FragmentManager.java:923)
        at com.amaze.filemanager.fragments.TabFragment.onSaveInstanceState(TabFragment.java:269)
        at android.support.v4.app.Fragment.performSaveInstanceState(Fragment.java:2626)
        at android.support.v4.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManager.java:2910)
        at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:2971)
        at android.support.v4.app.FragmentController.saveAllState(FragmentController.java:134)
        at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:591)
        at android.support.v7.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:510)
        at com.amaze.filemanager.activities.MainActivity.onSaveInstanceState(MainActivity.java:1090)
        at android.app.Activity.performSaveInstanceState(Activity.java:1302)
        at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1312)
        at android.app.ActivityThread.callCallActivityOnSaveInstanceState(ActivityThread.java:4109)
        at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3511)
        at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3571)
        at android.app.ActivityThread.-wrap20(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1378)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:148)
        at android.app.ActivityThread.main(ActivityThread.java:5443)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
@EmmanuelMess EmmanuelMess added the Issue-Bug Related unexpected behavior or something worth investigating. label Dec 28, 2018
@devmike01
Copy link

Hi @EmmanuelMess . I investigated the bug and fortunately I was able to find what went wrong. I fixed it by checking if fragmentManager.executePendingTransactions() is true before putting the fragment in the fragment manager... Look for for (Fragment fragment : fragments){...} in your onSaveInstanceState method inside TabFragment. Wrap the statements inside it with if (fragmentManager.executePendingTransactions()){...}. It should now look like this...

if (fragmentManager.executePendingTransactions()) {
    fragmentManager.putFragment(outState, "tab" + i, fragment);
    i++;
}

Hope it help.

@VishalNehra
Copy link
Member

Exception

  • User Action: UI Error
  • Request: Application crash
  • Version: 3.5.2
  • OS: Linux Nokia/TA-1053_00WW/ND1:9/PKQ1.181105.001/00WW_6_19B:user/release-keys 9 - 28
  • Device: ND1
  • Model: TA-1053
  • Product: TA-1053_00WW
Crash log

java.lang.IllegalStateException: Fragment MainFragment{bf23580 (fe765438-4b89-4b46-a91b-eb96bf0aad7e)} is not currently in the FragmentManager
at androidx.fragment.app.FragmentManagerImpl.putFragment(FragmentManagerImpl.java:350)
at com.amaze.filemanager.ui.fragments.TabFragment.onSaveInstanceState(TabFragment.java:226)
at androidx.fragment.app.Fragment.performSaveInstanceState(Fragment.java:2766)
at androidx.fragment.app.FragmentManagerImpl.saveFragmentBasicState(FragmentManagerImpl.java:2289)
at androidx.fragment.app.FragmentManagerImpl.saveAllState(FragmentManagerImpl.java:2348)
at androidx.fragment.app.FragmentController.saveAllState(FragmentController.java:151)
at androidx.fragment.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:513)
at androidx.appcompat.app.AppCompatActivity.onSaveInstanceState(AppCompatActivity.java:533)
at com.amaze.filemanager.ui.activities.MainActivity.onSaveInstanceState(MainActivity.java:1150)
at android.app.Activity.performSaveInstanceState(Activity.java:1549)
at android.app.Instrumentation.callActivityOnSaveInstanceState(Instrumentation.java:1444)
at android.app.ActivityThread.callActivityOnSaveInstanceState(ActivityThread.java:4836)
at android.app.ActivityThread.callActivityOnStop(ActivityThread.java:4184)
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:4148)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:4223)
at android.app.servertransaction.StopActivityItem.execute(StopActivityItem.java:41)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1823)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:6729)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


@VishalNehra
Copy link
Member

Keeping this issue open and moving to 3.7 as the fix was just a band-aid. Ideally we should not be saving the whole fragment to instance state, and use viewmodel for TabFragment.
This can easily cause OutOfMemoryException as we experienced in past with MainFragment.

@VishnuSanal VishnuSanal removed their assignment Sep 28, 2021
@VishnuSanal VishnuSanal reopened this Sep 30, 2021
VishnuSanal added a commit that referenced this issue Jun 27, 2023
Signed-off-by: VishnuSanal <t.v.s10123@gmail.com>
@Obolrom Obolrom mentioned this issue Jul 1, 2023
@VishnuSanal VishnuSanal linked a pull request Sep 1, 2023 that will close this issue
4 tasks
@VishalNehra VishalNehra modified the milestones: v3.9, v4.0 Feb 17, 2024
@VishnuSanal VishnuSanal mentioned this issue May 4, 2024
VishnuSanal added a commit that referenced this issue Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UIUX Related to user interface/experience (e.g. dialogs, notifications). Issue-Bug Related unexpected behavior or something worth investigating.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants