IllegalStateException in Drawer.onDrawerClosed: fragment transaction committed after onSaveInstanceState

Đang mở Phù hợp với người mới
#4,786 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
77/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
android, kotlin
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu trong Drawer.java, đặc biệt là ở onDrawerClosed() tại dòng 776 và phần thiết lập giao dịch cho “FTP server” và “Apps” tại dòng 537 và 620. Kiểm tra cách drawer xử lý một giao dịch fragment đang chờ sau khi activity lưu trạng thái, sau đó chạy các bài kiểm thử drawer hoặc fragment liên quan nếu có. Công việc hoàn tất khi các thao tác của drawer không còn gây lỗi nếu hoạt ảnh đóng kết thúc sau khi trạng thái được lưu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Kotlin
Star
6.5k
Fork
1.7k
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TeamAmaze/AmazeFileManager

Tất cả issue của TeamAmaze/AmazeFileManager

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.