Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data sync] App freezes temporarily while new LOIs are being downloaded #2862

Closed
gino-m opened this issue Nov 21, 2024 · 3 comments · Fixed by #2865
Closed

[Data sync] App freezes temporarily while new LOIs are being downloaded #2862

gino-m opened this issue Nov 21, 2024 · 3 comments · Fixed by #2865
Assignees
Labels
type: bug Something isn't working

Comments

@gino-m
Copy link
Collaborator

gino-m commented Nov 21, 2024

  • App freezes after clicking "submit" - dragging the map causes app timeout
  • Also freeze on any change to remove survey, jobs, or LOIs
@gino-m gino-m added the type: bug Something isn't working label Nov 21, 2024
@gino-m gino-m self-assigned this Nov 21, 2024
@gino-m
Copy link
Collaborator Author

gino-m commented Nov 22, 2024

  • Consider performing the marker and polygon initialization on a background thread to avoid blocking the main thread. Note that adding to the map will still need to be done on the main thread.
  • Debouncing and only emitting unique LOI features in HomeScreenMapContainerViewModel avoids us from thrashing the UI when updated/new LOIs are trickling in:
   @OptIn(FlowPreview::class)
   mapLoiFeatures =
      activeSurvey.flatMapLatest {
        if (it == null) flowOf(setOf())
        else
          getLocationOfInterestFeatures(it)
            .debounce(1000.milliseconds)
            .distinctUntilChanged()
            .combine(this::updatedLoiSelectedStates)
      }
  • FeatureManager.setFeatures() and downstream ClusterManager and *Render could be updated to add and remove featurs in batch rather than individually. <-- Maps SDK only allows these to be added one at a time.
  • Note that ClusterManager.add() should also be renamed to put(), since the element with the existing tag name is replaced.

@gino-m
Copy link
Collaborator Author

gino-m commented Nov 22, 2024

Consider performing the marker and polygon initialization on a background thread to avoid blocking the main thread. Note that adding to the map will still need to be done on the main thread.

I tried only adding the markers and polygons on the UI thread, but there was no noticeable improvement.

@gino-m
Copy link
Collaborator Author

gino-m commented Nov 22, 2024

I just realized I was using the Profiler incorrectly, and learned something surprising. It's not the Maps SDK updates which are blocking - it appears to be the proto conversion process, which is happening on the main thread!

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant