commons-app / apps-android-commons

The Wikimedia Commons Android app allows users to upload pictures from their Android phone/tablet to Wikimedia Commons
https://commons-app.github.io/
Apache License 2.0
978 stars 1.18k forks source link

Reduce delay between peer reviews #5743

Open sivaraam opened 1 month ago

sivaraam commented 1 month ago

What is the user problem or growth opportunity you want to see solved?

The overall Peer Review screen incurs a lot of delays. This is observed even on good internet connections. As a consequence, the usability of this on a throttled connection is questionable. We should explore if there are ways to improve this situation.

How do you know that this problem exists today? Why is this important?

The peer review screen takes a few seconds in order to load the image to be currently reviewed by the user. The fix for this is important as it would help improve the usability of the feature and would make it accessible to a wider range of users.

Who will benefit from it?

All users. Especially those who are on limited connection environments would benefit out of this.

Anything else you would like to add?

This has been reported by a user here.

Here's a screen recording shared by the user showcasing the delay and the following is the supplementary note about the video:

It started spinning after I approved the photo. I hit the skip button just to show that nothing was happening

sivaraam commented 1 month ago

The first part of this enhancement would be to identify which part contributes to the slow loading of the image in the first place. Is it because a full-size image is being loaded? Or is a thumbnail itself taking several seconds due to some factor?

nicolas-raoul commented 1 month ago

Actually, peer review becomes slower and slower. After reviewing a few dozen images, it takes several minutes between each review.

sivaraam commented 1 month ago

Looks like we should generalise this enhancement as "identify and correct slowness issues in peer review", then.

RitikaPahwa4444 commented 1 month ago

Is this happening because we check if the image has been reviewed already from a database table?

sivaraam commented 1 month ago

It could be a reason. The matter is that no one is certain about the actual cause of the slowness. Someone would have to figure out the same. If you're interested in doing so, feel free to 🙂

nicolas-raoul commented 1 month ago

Just a wild guess (I have not checked the code), but if the algorithm is like below, it is no surprise that it becomes slower and slower:

  1. Retrieve last 20 uploads, pick a random one and forget the rest.
  2. Check whether the user has never reviewed that upload. If yes review it, else go back to step 1.
RitikaPahwa4444 commented 1 month ago

I'd added that table, so I thought we're reading the db too frequently. But we're seemingly following the same algorithm as Nicolas has mentioned, so it's about frequent network calls too.

Not sure if this is because I'm using a different device, but the app isn't even fetching the very first image for me. I won't term this as slow but rather call it non-functional. Is the MediaWiki API working?

I'm using the version that's available on the Play Store. I'll try prodDebug from the latest main in some time. I'm running the app on API level 34.

sivaraam commented 1 month ago

I think the API works fine. It loads the image for me but after some delay of few seconds after the title appears.

Screenshot_2024-05-28-22-04-57-56_d5db3f3edc380047609fe9c266f7c566

RitikaPahwa4444 commented 1 month ago

I'd cleared storage to check if it's happening with a large table. Skipped that image, and others started appearing quickly. Now it's gets stuck on a few pictures, I skip them to review other images.

sivaraam commented 4 weeks ago

I do notice the images taking several seconds (5-10 sometimes) to load. It might be because we load a full-sized image rather than a thumbnail. We could explore loading a thumb in the review screen and show the full-sized image on a tap.

In any case, I suppose you should be able to see the full-sized image load properly when you tap on the image.

psh commented 2 weeks ago

What I am seeing is that the ReviewActivity runRandomizer() method is getting called many times (in one test, 30+ times), and there are (at worst) a couple of hundred API calls going on until it finds the next image to review. Each API call is taking 150-250ms each, so you can imagine how long it took for some of the slow images to appear!

nicolas-raoul commented 2 weeks ago

Thanks Paul for identifying the root cause!

So the task here is to re-implement the way we find the next image to review, using what API calls (for context the feature was implemented during a hackathon). We should probably make 1 API call to retrieve like 50 pictures to review, then cache the results and use them locally as long as they are not over 1 day old.