IllegalStateException in Drawer.onDrawerClosed: fragment transaction committed after onSaveInstanceState

Abierto Apto para principiantes
#4,786 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
77/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
android, kotlin
Área
mobile

Línea de trabajo

Empieza en Drawer.java, especialmente en onDrawerClosed() en la línea 776 y en la configuración de las transacciones para “FTP server” y “Apps” en las líneas 537 y 620. Comprueba cómo gestiona el drawer una transacción de fragmento pendiente después de que la actividad guarde su estado y, luego, ejecuta las pruebas pertinentes del drawer o de fragmentos, si están disponibles. El objetivo se cumple cuando las acciones del drawer ya no provocan fallos si su animación de cierre termina después de guardar el estado.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug
The app crashes with an IllegalStateException when the navigation drawer finishes closing after the activity has already saved its state. Drawer.onDrawerClosed() calls pending_fragmentTransaction.commit() (Drawer.java:776), and the FragmentManager rejects this once state has been saved. The pending transaction is created in the drawer actions for "FTP server" and "Apps" (Drawer.java lines 537 and 620), which are committed only when the drawer finishes closing.

Found with Android Monkey testing. I could not reproduce it manually, so the exact timing is unknown.

To Reproduce
Found by Monkey, 1 crash in a 5,000-event run, about 2.5 minutes after the start:

adb shell monkey -p com.amaze.filemanager.debug -s 2 --throttle 100 --ignore-security-exceptions --pct-touch 70 --pct-motion 20 --pct-majornav 5 --pct-appswitch 5 --pct-anyevent 0 --pct-trackball 0 --pct-nav 0 --pct-syskeys 0 -v -v 5000

Monkey timing varies, so the same seed may not crash at the same point.

Suspected manual path (untested): open the side drawer, tap "Apps" or "FTP server", and send the app to the background (Home) before the drawer's close animation completes.

Expected behavior
No crash. The transaction should not be committed while the state is saved. For example, check FragmentManager.isStateSaved() first, or use commitAllowingStateLoss() if losing this transaction is acceptable.

Stack trace
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1612)
at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1652)
at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:341)
at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:306)
at com.amaze.filemanager.ui.views.drawer.Drawer.onDrawerClosed(Drawer.java:776)
at com.amaze.filemanager.ui.views.drawer.Drawer$1.onDrawerClosed(Drawer.java:243)
at androidx.drawerlayout.widget.DrawerLayout.dispatchOnDrawerClosed(DrawerLayout.java:891)
at androidx.drawerlayout.widget.DrawerLayout.updateDrawerState(DrawerLayout.java:861)
at androidx.drawerlayout.widget.DrawerLayout$ViewDragCallback.onViewDragStateChanged(DrawerLayout.java:2249)
at androidx.customview.widget.ViewDragHelper.setDragState(ViewDragHelper.java:920)
at androidx.customview.widget.ViewDragHelper$2.run(ViewDragHelper.java:345)
(Full crash log attached.)

Smartphone

  • Device: Android Emulator, Medium Phone (arm64)
  • OS: Android API 37
  • Rooted: No
  • Version: built from source, branch release/4.0, commit 94afab32b (app/build.gradle versionName 3.11.3; latest published release is v3.11.4, not tested)

Additional context
Found as part of a university software-testing course project, using Monkey testing on a debug build.

Lenguaje dominante
Kotlin
Estrellas
6.5k
Forks
1.7k
Merge medio
1 d 1 h
PR fusionados (30 d)
10

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de TeamAmaze/AmazeFileManager

Todos los issues de TeamAmaze/AmazeFileManager

Issues similares

Más issues de Kotlin

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.