IllegalStateException in Drawer.onDrawerClosed: fragment transaction committed after onSaveInstanceState

Aperta Adatta ai principianti
#4,786 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
77/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, kotlin
Ambito
mobile

Direzione di ricerca

Inizia da Drawer.java, in particolare da onDrawerClosed() alla riga 776 e dalla configurazione delle transazioni per “FTP server” e “Apps” alle righe 537 e 620. Controlla come il drawer gestisce una transazione di fragment in sospeso dopo che l’attività ha salvato il proprio stato, quindi esegui i test pertinenti del drawer o dei fragment, se disponibili. Il lavoro è completato quando le azioni del drawer non causano più arresti anomali se l’animazione di chiusura termina dopo il salvataggio dello stato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Kotlin
Stelle
6.5k
Fork
1.7k
Merge medio
1g 1h
PR unite (30g)
10

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TeamAmaze/AmazeFileManager

Tutte le issue di TeamAmaze/AmazeFileManager

Issue simili

Altre issue su Kotlin

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.