apps-android-commons icon indicating copy to clipboard operation
apps-android-commons copied to clipboard

[Bug]: Three small problems in Nearby pin details loading (stale bookmark, duplicate items, empty places cached)

Open Medhansh-741 opened this issue 2 weeks ago • 2 comments

Summary

While working on #7357 I found three small problems in NearbyPlaceDetailsLoader. They are all in the same loading code, so I put them in one issue. Each one has a unit test that fails on main (dac8a6b). Links are to that commit.

  1. A bookmark made while pins are loading can be undone

Each batch looks up the bookmark state right after its request (L214). The collecting loop applies clicks and bookmark changes after each batch and then moves its cursor past them (L424-L436). If a pin's batch comes back after another batch was handled, processResults replaces the whole group with the old bookmark state (L303), and the change is not applied again. The pin then shows as not bookmarked until the next reload. This is the same area as the updatedGroups note in the #7361 review.

  1. The same item twice: both pins end up at one location

A custom query can return the same item at two locations (the default queries group by item). Rows are matched to pins by QID, so both pins get the same Place object (L203-L207), and processResults sets the location on that shared object (L297-L298), so the first pin moves to the second one's location. If #7177 replaces the SPARQL editor, this one may not be reachable anymore.

  1. Failed requests save empty places to the cache

When a request fails, the fallback keeps the grey place (L249), and a place missing from an answer does the same (L209). processResults then saves it to the cache with an empty name (L304-L305). The next load treats an empty name as not cached, so the user doesn't see it, but it writes useless rows on every failed load (for example with no network or a 429).

Steps to reproduce

These are timing and data cases, so I reproduced them with unit tests in NearbyPlaceDetailsLoaderTest, using the same setup as the tests from #7361:

  1. Three batches. Pin Q10 is opened and bookmarked while its batch is still out, and another batch arrives in between.
  2. Two pins for the same QID at latitudes 1 and 5.
  3. Every request fails with IOException.

Expected behaviour

  1. Q10 stays bookmarked.
  2. Each pin keeps its own location.
  3. Nothing is saved to the cache.

Actual behaviour

  1. assertTrue(markerLabelList[10].isBookmarked) fails. The same test with the batches arriving in order passes, so it's the order that breaks it.
  2. expected:<[1.0, 5.0]> but was:<[5.0, 5.0]>
  3. places saved to the cache expected:<0> but was:<2>

Device name

Not device specific (unit tests).

Android version

Not device specific.

Commons app version

main (dac8a6b)

Device logs

Not applicable, see the test results above.

Screenshots

None.

Would you like to work on the issue?

Yes

Medhansh-741 avatar Nov 18 '26 11:11 Medhansh-741

Assigned to you, @Medhansh-741! Thanks!

nicolas-raoul avatar Nov 18 '26 11:11 nicolas-raoul

@nicolas-raoul I opened #7369 for this.

Medhansh-741 avatar Nov 18 '26 13:11 Medhansh-741