Skip to content

Update firebase mappings to improve performance on large surveys - #3868

Open
andreia-ferreira wants to merge 6 commits into
masterfrom
andreia/3866/improve-large-survey-load
Open

Update firebase mappings to improve performance on large surveys#3868
andreia-ferreira wants to merge 6 commits into
masterfrom
andreia/3866/improve-large-survey-load

Conversation

@andreia-ferreira

Copy link
Copy Markdown
Collaborator

Towards #3866

Loading large surveys could be very slow. One of the factors was using expensive java reflection lookups on every field of every LOI as well as storing unused properties that could be very large (especially if whisp integration is enabled on the survey). This PR optimizes that:

  • Added LoiGeometryConverter to read geometry directly from the Firestore document instead of through the reflection-based proto mapper
  • Filter LOI properties and only store the ones that the app uses
  • Cache resolved builder methods (declaredFunctions was re-running for every field of every document)
  • Set FIRESTORE_LOGGING_ENABLED as false in release builds, as writing down logs for large surveys can be quite heavy

After testing with some user surveys from Vietnam, these changes were shown to cut in half the time needed to download

@shobhitagarwal1612 PTAL?

@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.57895% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.78%. Comparing base (c61510d) to head (1d57277).

Files with missing lines Patch % Lines
...ndroid/data/remote/firebase/schema/LoiConverter.kt 64.70% 0 Missing and 6 partials ⚠️
...remote/firebase/protobuf/FirestoreToProtobufExt.kt 57.14% 2 Missing and 1 partial ⚠️
...mote/firebase/protobuf/MessageLiteReflectionExt.kt 85.00% 0 Missing and 3 partials ⚠️
...ava/org/groundplatform/android/common/Constants.kt 0.00% 0 Missing and 1 partial ⚠️
...ata/remote/firebase/schema/LoiGeometryConverter.kt 96.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3868      +/-   ##
============================================
+ Coverage     67.70%   67.78%   +0.07%     
- Complexity     1859     1870      +11     
============================================
  Files           411      412       +1     
  Lines         10857    10910      +53     
  Branches       1425     1432       +7     
============================================
+ Hits           7351     7395      +44     
- Misses         2767     2769       +2     
- Partials        739      746       +7     
Files with missing lines Coverage Δ
...ava/org/groundplatform/android/common/Constants.kt 66.66% <0.00%> (-33.34%) ⬇️
...ata/remote/firebase/schema/LoiGeometryConverter.kt 96.77% <96.77%> (ø)
...remote/firebase/protobuf/FirestoreToProtobufExt.kt 70.76% <57.14%> (-1.37%) ⬇️
...mote/firebase/protobuf/MessageLiteReflectionExt.kt 68.42% <85.00%> (+5.73%) ⬆️
...ndroid/data/remote/firebase/schema/LoiConverter.kt 78.04% <64.70%> (-12.87%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant