-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Made Split to Nearby Query into a fast query for coordinates + a details query for each pin #5731
Conversation
Testing now. Just wondering: Is there a specific reason why your branch is called |
There's no specific reason for it 😄 From next time I will try to follow proper naming. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind implementing a loop that asynchrously loads each item's details, for all shown points? Depending on the user's settings it will make many points disappear, which is not ideal user experience but it is the best we can do while having fast nearby maps in areas with many items.
Thanks! 🙂
Sure, I will do asynchronous loop to load pin's details |
Hey @nicolas-raoul, I'm bit confused here. Should the queries look like given below?
|
Sounds good! :-) For the second query, you can specify the QIDs of the pins, that will make the query much faster. |
By the way, I believe it would be user-friendly to first show pins in grey color to mean "unfiltered". Then upon receiving the result from the second request, hide the pins that do not match the filter, and set the normal color to the pins that match the filter. What do you think? 🙂 |
Yeah, That would be great! |
Hello @nicolas-raoul, I have improvised query as per suggestions by you and it's working fine for the smaller regions WhatsApp.Video.2024-05-16.at.15.15.29_37c183a9.mp4But I have faced an issue because we are using List of QID (which becomes really large for city like capital of India) the server returns error 414 which is because our url length exceeds a limit (which is because of the large query) WhatsApp.Video.2024-05-16.at.15.16.45_392342b7.mp4How about replacing the List of QID with similar method we had earlier? |
Would you mind splitting the second query into several queries of 50 QIDs max, and using the results as they come? Ideally sort them by their distance to the center of the search rectangle, then run the queries starting from the nearest 50 QIDs. Sorry to add something again, but when a not-yet-loaded QID is tapped by the user, it would be great to run the second query for that point, in parallel with the above, it will probably return the result fast and the user will see the label/class/filter status/etc without having to wait for all points to load. |
Thank you for suggestion and I feel it will make queries even better. And I have added that when pins are not loaded still the user can get the details for a pin. Screen_Recording_20240516_164159_Commons.mp4 |
Hello Nicolas, I have divided the second query into batches fixing the issue we were facing due to large size of second query. Now the first query has became more effective. VID-20240517-WA0007.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is getting better and better, keep up the great work :-)
Brilliant work on the SPARQL query especially!
app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.java
Outdated
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.java
Outdated
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java
Outdated
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java
Outdated
Show resolved
Hide resolved
Hello Nicolas, Thanks for the suggestions and now loading of pins has became even more efficient. WhatsApp.Video.2024-05-18.at.11.13.21_560bd12d.mp4 |
Looks fantastic! I will try it as soon as I get home. 🙂 |
Hi @nicolas-raoul, on digging I am able to find that issue was caused by ongoing network call which was not stopped on starting new call. Now I have updated the code, I hope it should fix up the issue. WhatsApp.Video.2024-05-19.at.10.03.18_d70e1a6f.mp4 |
I am experiencing several unexpected things, especially when swgitching to other apps or when the screen goes black: screen-20240519-213301.mp4Also, maybe modifying the default zoom level would be good (zoomed more, mening it loads less items by default). |
Sure, I will update the zoom level ;-) I tried switching apps. It moves the map to the default location VID-20240519-WA0003.mp4Actually It wasn't clear from the video provided. On switching apps the map return to the my location (in my case) |
Let's say the map is fully loaded, including points details (exist or not, etc). Then when I turn the screen off and on again, all points on the map turned back to grey again, and it starts sending requests again 3-by-3. It should not reload unless it is kicked ou of memory (this happens on a device with lots of memory and no other running app so memory is not the issue). |
Hey Nicolas, I have fixed the unnecessary reloads caused onResume. WhatsApp.Video.2024-05-29.at.12.21.09_a7068d1b.mp4We may also need to implement method to load pending pins which are not loaded on changing the apps as it returns <-- HTTP FAILED: java.io.InterruptedIOException, I am working over it and will also share a commit for it ASAP |
Hi @nicolas-raoul, I have fixed the bug in 2251c62 WhatsApp.Video.2024-07-10.at.18.31.15_d1eac0ec.mp4 |
|
||
private List<Place> updatedPlaceList; | ||
private LatLng updatedLatLng; | ||
private boolean searchble; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo?
locationPermissionGranted(); | ||
if (lastFocusLocation == null && lastKnownLocation == null) { | ||
locationPermissionGranted(); | ||
}else if (updatedPlaceList != null){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: space between } and else
app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java
Show resolved
Hide resolved
}); | ||
} | ||
|
||
private void savePlaceToDB(Place place) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc.
In Java we ususally use full words: savePlaceToDatabase
app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java
Show resolved
Hide resolved
app/src/main/java/fr/free/nrw/commons/nearby/presenter/NearbyParentFragmentPresenter.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I load Nearby for the first time, it loads a much wider rectangle than what is seen on screen.
Then when I move the map and let the pins refresh, that time only pins visible on screen are loaded.
Any idea what makes it load too many pins the first time? It makes the initial query longer and makes many unneeded queries to the server.
Fixed this issue in 6fed9f4 |
Hello @nicolas-raoul, I have added jcenter in 4f7cbfc which seems to be fix for https://github.com/commons-app/apps-android-commons/actions/runs/10131832421/job/28015018616?pr=5731
as this library is hosted on jcenter https://mvnrepository.com/artifact/com.dinuscxj/circleprogressbar?repo=jcenter |
Maybe not a big issue, but I see the pin at the top appearing and disappearing: PXL_20240730_012259644.mp4sorry for the bad video quality |
If possible can you please share the location over zulip (for testing) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, you are quickly approaching mergeability for this pull request :-)
@@ -204,6 +206,7 @@ public static class Table { | |||
static final String COLUMN_COMMONS_LINK = "location_commons_link"; | |||
static final String COLUMN_PIC = "location_pic"; | |||
static final String COLUMN_EXISTS = "location_exists"; | |||
static final String COLUMN_ENTITY_ID = "location_entity_id"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a comment explaining why this line is needed? And whether it can be empty, and an example value. Thanks!
private PlaceAdapter adapter; | ||
private GeoPoint lastMapFocus; | ||
private NearbyParentFragmentInstanceReadyCallback nearbyParentFragmentInstanceReadyCallback; | ||
private boolean isAdvancedQueryFragmentVisible = false; | ||
private Place nearestPlace; | ||
private volatile boolean stopQuery; | ||
|
||
private List<Place> updatedPlaceList; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updatedPlaceList -> updatedPlacesList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing, I have made all suggested changes in the newer commit.
I tested more there are still a few bugs but soon mergeable I think. 🙂 The biggest problem: It seems like the first time (for instance after installing the app) Nearby pins do not load, until I switch to home activity then come back: screen-20240803-222510.mp4 |
I have shared a newer commit fixing this bug. Can you please test it. WhatsApp.Video.2024-08-03.at.21.09.22_36e5bf8f.mp4 |
Fantastic, thanks Kanahia for this pull request, it is a great improvement! |
Description (required)
Fixes #4560
What changes did you make and why?
Tests performed (required)
Tested prodDebug on Samsung S21 FE with API level 33.
Screenshots (for UI changes only)
WhatsApp.Video.2024-05-14.at.20.36.17_5a90b1f7.mp4