Skip to content

Fix ConcurrentModificationException when dragging points in Mapbox#7190

Merged
grzesiek2010 merged 2 commits intogetodk:masterfrom
grzesiek2010:COLLECT-7185
Apr 21, 2026
Merged

Fix ConcurrentModificationException when dragging points in Mapbox#7190
grzesiek2010 merged 2 commits intogetodk:masterfrom
grzesiek2010:COLLECT-7185

Conversation

@grzesiek2010
Copy link
Copy Markdown
Member

@grzesiek2010 grzesiek2010 commented Apr 17, 2026

Closes #7185

Why is this the best possible solution? Were any other approaches considered?

When a point annotation is dragged and released, Mapbox invokes our onAnnotationDragFinished() callback before finishing its internal processing. We were calling featureDragEndListener.onFeature() synchronously inside that callback, which triggered a chain of events that caused the polyline feature to be disposed and recreated all before onAnnotationDragFinished() returned. This modified Mapbox's internal state while it was still being processed, resulting in a ConcurrentModificationException.

The fix defers the onFeature() call using Handler(Looper.getMainLooper()).post {}, so the feature update happens after Mapbox finishes processing the drag event.

A more optimal solution could be to update the polyline/polygon in place rather than disposing and recreating it entirely (maybe that would also fix this issue). However, the current pattern is shared across all three map engines, so changing it would require a broader refactor. Given that we are planning to migrate to MapLibre in the near future, this does not seem worth addressing at this point.

How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?

Only the code responsible for dragging points in geotrace/geoshape with Mapbox has been changed, so testing can be focused on this functionality only.

Do we need any specific form for testing your changes? If so, please attach one.

The All question types form is ok.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

No.

Before submitting this PR, please make sure you have:

  • added or modified tests for any new or changed behavior
  • run ./gradlew connectedAndroidTest (or ./gradlew testLab) and confirmed all checks still pass
  • added a comment above any new strings describing it for translators
  • added any new strings with date formatting to DateFormatsTest
  • verified that any code or assets from external sources are properly credited in comments and/or in the about file.
  • verified that any new UI elements use theme colors. UI Components Style guidelines

Copy link
Copy Markdown
Member

@seadowg seadowg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I think we should have comments before the post calls to make sure it's clear why this is happening.

@grzesiek2010 grzesiek2010 merged commit d670a89 into getodk:master Apr 21, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Crash after moving point in a geoshape/trace on Mapbox

2 participants