MerginMaps / mobile

Mobile app for Mergin Maps 📲. Open QGIS projects and manage vector data on your phone, even offline 📶 (Android/iOS/Windows app)
https://merginmaps.com
GNU General Public License v2.0
280 stars 62 forks source link

App will freeze in some cases when an integer field has 'not null' constraint and no default value #3417

Closed raherin closed 1 month ago

raherin commented 1 month ago

I have identified a condition where the app will freeze when there is a field with an integer data type that has a not null constraint and no default value is set. There are also two other specific conditions to cause the freeze. The form must be long enough that the user has to scroll to see all of the fields and it will not freeze until a second feature is created after editing or creating a feature and saving it. I have created an example project support/test-not-null-int to test the issue. To recreate the problem:

  1. create a survey layer that:
  1. give the integer field a 'not null' constraint but do not set a default value
  2. synchronise the project with the QGIS plugin
  3. download the project and open it in the app
  4. record a new feature on the survey layer, make sure all of the constraints are met and save the feature
  5. press the '+' button and 'record' to add a second feature
  6. when the form view opens, scroll up and down the form
  7. the app will freeze

I have tested this on a Samsung A53 with Android 14 installed. At least one other user has reported a similar issue on their Android 14 device.

PeterPetrik commented 1 month ago

I can reproduce it with support/test-not-null-int even in macOS debug build . It can be replicated even in qt6.6.0 build on macOS

raherin commented 1 month ago

In addition to the above conditions, I was able to reproduce app freezes with other data type and widget combinations with 'not null' constraints. I've created another project to reproduce this support/form-freeze-test

Using the example project, the following conditions caused freezing in the app:

Data type Widget type Contraint Default When did app freeze?
text Value map not null no default (1st feature edited after last sync)
int32 range not null no default (1st feature edited after last sync)
int32 range "number" >= 1 no default (1st feature edited after last sync)
text attachment(photo) not null no default (2nd feature edited after last sync)
tomasMizera commented 1 month ago

@raherin can you reproduce this even without 'not null' constraints?

raherin commented 1 month ago

@tomasMizera we also got app crashes on iPad. Though it needed to be in landscape mode so that you had to scroll to see the whole form. If it is in portrait mode and you do not need to scroll, the app does not crash. Also the app did not crash if values were entered to not null fields before scrolling. It only crashed when not null fields are empty and you scroll on the form.

tomasMizera commented 1 month ago

Thanks @raherin for testing this out!

jozef-budac commented 1 month ago

I can't reproduce the crash on the current 2024.2.0 RC. @raherin , can you please verify it also?