The steps were reported by my testing tool (note these steps may not be complete or shortest, but it could lead to the crash). I annotated the action on some key steps, and hope they are useful to help you diagonise the root cause. I tried to manually reproduce this issue, but it is not easy for me to come up the valid trace. Maybe you folks are more familiar with the code and can identify the root cause more quickly :)
Step 1:

Step 2 (click Empty):

Step 3:

Step 4:

Step 5:

Step 6:

Step 7:

Step 8:

Step 9 (click the undo icon):

Step 10:

Step 11 (click Empty Cards):

No crash
Crash happens
This crash was found in the recent released version 2.9.6 on an Android 6.0 device.
FATAL EXCEPTION: AsyncTask #1
Process: com.ichi2.anki, PID: 4195
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'long java.lang.Long.longValue()' on a null object reference
at com.ichi2.libanki.Collection.genCards(Collection.java:761)
at com.ichi2.libanki.Collection.genCards(Collection.java:708)
at com.ichi2.libanki.Collection.emptyCids(Collection.java:966)
at com.ichi2.async.DeckTask.doInBackGroundFindEmptyCards(DeckTask.java:1500)
at com.ichi2.async.DeckTask.doInBackground(DeckTask.java:346)
at com.ichi2.async.DeckTask.doInBackground(DeckTask.java:70)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more
Enter an [ x ] character to confirm the points below:
[ X ] I have read the support page and am reporting a bug or enhancement request specific to AnkiDroid
[ X ] I have checked the manual and the FAQ and could not find a solution to my issue
[ X ] I have searched for similar existing issues here and on the user forum
This is an outstanding report, thank you so much!
Despite this, I still can't replicate it.
Some relevant code
Line of the crash
https://github.com/ankidroid/Anki-Android/blob/b06592eae0aa642753073c8c8af192692f4c8ff1/AnkiDroid/src/main/java/com/ichi2/libanki/Collection.java#L761
Changing settings rebuilds the deck
https://github.com/ankidroid/Anki-Android/blob/916f55eec5a830d33c2505074d206b63559753cc/AnkiDroid/src/main/java/com/ichi2/anki/FilteredDeckOptions.java#L423-L430
This happens in the wild as well, so not just an automated testing crash. (Saw a few on 2.8.4 as well)
Samples
2.9.6:
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/eeea7b9f-ac9a-4a76-b2ab-a868bd7e1f5e
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/5367d828-44d0-4496-b5fe-47d3a65b1fa5
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/7e2a3606-6485-4d3c-83eb-bdc8abb5b693
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/b002f696-fa11-4e19-b297-f3fe7993edf6
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/41d8e299-ff5a-48ec-aba8-4592988f7d08
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/d28e9823-c616-46ba-966e-9d60ab5f980f
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/d28e9823-c616-46ba-966e-9d60ab5f980f
2.9.5:
https://couchdb.ankidroid.org/acralyzer/_design/acralyzer/index.html#/report-details/73b43a4b-a0dc-48d1-bd83-d729860fea63
Note: none of the above have schedVer (sched V2) set.
Thanks for your quick reply and confirmation, @david-allison-1 !
Do you have logs from before this happens (I'm specifically looking for how the action for "Undo" action occurred, and where the notes were).
Yes, I have the whole trace. In fact, I tried to maually come up a valid trace. But, up to now, I cannot find a shortest trace. As you said, the main issue is to find the pivot state (e.g., the page with "undo") under which the issue happens. The current trace I provided was cut off by myself from the long trace (the trace is too long...). One note is that: the event in the trace are all normal UI actions without any hacky events there. It may be difficult for me to share the log with you, and you will also face the same situation as me (i.e., the prefix trace is too long).
Let me try again to see whether I can come up with a good trace to help fix this issue.
This happens in the wild as well, so not just an automated testing crash. (Saw a few on 2.8.4 as well)
This crash was found on the recent released version 2.9.6 (let me update this info in the issue to make it more clear).
Note: none of the above have schedVer (sched V2) set.
I do not quite understand this comment. To be honest, I am not quite familar with Ankidroid's code :)
@tingsu Thanks so much for the prompt reply!
Note: none of the above have schedVer (sched V2) set.
I do not quite understand this comment. To be honest, I am not quite familar with Ankidroid's code :)
I was stating to any developers reading that it's unlikely to be an issue with the V2 (experimental) scheduler. Sorry for the confusion.
I'm more than happy to delve through any type of logs if you're comfortable sending them.
gmail: davidallisongithub
Okay, thanks @david-allison-1 ! Let me prepare the log and send it to you later.
Hello 馃憢, this issue has been opened for more than 2 months with no activity on it. If the issue is still here, please keep in mind that we need community support and help to fix it! Just comment something like _still searching for solutions_ and if you found one, please open a pull request! You have 7 days until this gets closed automatically