getodk / collect

ODK Collect is an Android app for filling out forms. It's been used to collect billions of data points in challenging environments around the world. Contribute and make the world a better place! ✨📋✨
https://docs.getodk.org/collect-intro
Other
718 stars 1.38k forks source link

Savepoint not created if Collect is closed via going to Latest apps on some devices #6039

Open dbemke opened 7 months ago

dbemke commented 7 months ago

ODK Collect version

the store version 2024.1.3, the master version 2a06bf580b90d75d9e7089a1066ac469eb1f1589

Android version

12+

Device used

Pixel 7a

Problem description

On Android 12+ a savepoint isn’t created if Collect is closed via going to "Latest apps” (with navigation using 3 buttons, click the square) and swiping Collect up.

The issue doesn't occur on Android 10 (Redmi 9t), other devices will be described below Pixel 7a Android 14 example: https://github.com/getodk/collect/assets/56479916/4fd5f669-2605-464b-a4b9-eed51b4a4c0f

Steps to reproduce the problem

  1. Open a form.
  2. Fill/ Don’t fill something in the first question.
  3. Tap the square navigation button to see the "Latest apps”.
  4. Swipe up so that Collect is closed.
  5. Go back to Collect and open the form again.

A save point will be created if the user switches to another app using "Latest apps" (or hits the home button). This means that in reality, users will usually get save points when switching away from Collect.

Expected behavior

Depending on the version of Collect there should be:

Notes

It looks like Android 12 changes how "Recent apps" interacts with Activity#onSaveInstanceState which we use to trigger a save point. In Android 11 and under, opening recent apps is enough to cause onSaveInstanceState to be called, but in later Android versions the method isn't called until another app is switched to (or the user returns to the Home Screen). We'll need to find another way to trigger a save point so that it works across API versions.

srujner commented 7 months ago

Something similar is happening on Pixel 3a, Android 12 but only after Fresh Install

Steps to reproduce

  1. Freshly install Collect and open any form
  2. Don’t fill anything in the first question.
  3. Tap the square navigation button to see the "Latest apps”.
  4. Swipe up so that Collect is closed.
  5. Go back to Collect and open the form again.
  6. The Recover dialog will not show

Expected behavior The Recover dialog should be shown

Other information: It is happening on Android 12 only after Fresh install and only at the first attempt! If you'll repeat steps 1-5 then the savepoint will be created and the recovery dialog will appear

seadowg commented 7 months ago

I've done some testing and it looks like this is a problem on Android 12+. It seems like it's a change in Android's "Recent Apps" (that I can't find referenced anywhere). I'll update the issue description with my findings.

seadowg commented 7 months ago

We should discuss if we want to fix this as-is or change the feature so save points are created differently (i.e. on a timer on questions are answered).