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

[Bug]: Upload: nearby depictions are looked up again for every picture taken at the same spot

Open Medhansh-741 opened this issue 1 week ago • 3 comments

Summary

When an upload has several pictures taken at the same spot, the app looks up nearby Wikidata places (for depiction suggestions) once per picture, with the same query every time. This is the same thing #5316 fixed for the location categories, but for depictions.

The lookup is in FileProcessor.suggestNearbyDepictions. It tries a radius of 100 m, then 200 m, and so on up to 1 km, until it finds 5 places. So in a busy area it's 1 query per picture, and in a quiet area it can be up to 10 queries per picture.

Steps to reproduce

  1. Take 20 pictures at the same spot (with location on).
  2. Upload them together and stop at the depictions step.
  3. Look at the Wikidata Query Service requests in logcat.

Expected behaviour

The nearby places are looked up once for pictures taken within a few metres of each other.

Actual behaviour

In the center of Rome (Villa Borghese) I selected 20 pictures. The app processed 10 of them while I was on the first screen, and the same query (radius 100 m) went out 20 times, all answered. About half of these come from the depiction search. The other half come from the "Nearby place found" check (UploadRepository.checkNearbyPlaces), which sends the exact same 100 m query for each picture. This issue is only about the depiction search.

In a place with fewer than 5 Wikidata items within 1 km, each picture tries all 10 radii, so 20 pictures can send up to 200 queries (I checked this count with a unit test that mocks the API).

Device name

OnePlus CPH2491

Android version

16

Commons app version

main at caa5c9d (BetaDebug)

Device logs

00:01:29.456 --> GET query.wikidata.org/sparql  around Point(12.4923 41.9143) radius 0.10 km
00:01:29.615 --> GET query.wikidata.org/sparql  around Point(12.4923 41.9143) radius 0.10 km
00:01:29.677 --> GET query.wikidata.org/sparql  around Point(12.4923 41.9143) radius 0.10 km
00:01:29.688 --> GET query.wikidata.org/sparql  around Point(12.4923 41.9143) radius 0.10 km
... (20 requests like this in total for 10 processed pictures, all the same query)

Screenshots

(none)

Would you like to work on the issue?

Yes

Edit: I first wrote that 20 pictures sent 20 queries. Looking at the log again, it was 10 pictures, and each one sends the query twice (depictions plus the nearby place check), so I corrected the numbers above.

Medhansh-741 avatar Nov 24 '26 22:11 Medhansh-741

Assigned to you, @Medhansh-741! Thanks!

nicolas-raoul avatar Nov 24 '26 22:11 nicolas-raoul

Thanks @nicolas-raoul!

What I'll do, same idea as #7420:

  1. Look up nearby places only once for pictures of this upload taken within 50 m of each other.
  2. If that lookup fails (network error, server busy), let the next picture of that place try again, so the depiction suggestions aren't lost.

Could you also set the Bug type on this issue? I can't set it myself. Or, if you think it's fine, triage access would let me set the type on my own issues so you don't have to.

Medhansh-741 avatar Nov 24 '26 22:11 Medhansh-741

@nicolas-raoul opened #7426 for this. Pictures taken at the same spot now search nearby places for depictions once instead of once per picture, and the suggestions still show up. It's on top of #7420, so that one should go in first.

Medhansh-741 avatar Nov 25 '26 07:11 Medhansh-741