Page MenuHomePhabricator

[GSOC 2024 Proposal]: Migrate from RxJava to Kotlin Coroutines & Flows and Improve Nearby
Open, Needs TriagePublic

Description

Profile Information

Name: Shashank Kumar
Email: shashank.kumar.phe22@itbhu.ac.in
Education: Indian Institute of Technology (BHU), Varanasi
Github : shashankiitbhu
LinkedIn : Shashank Kumar
Location: Varanasi, India
Other Communication modes: Discord, Zulip, Telegram
Typical working hours: 9 am - 10 pm (IST) UTC+5:30

Synopsis

  • Wikimedia Commons Android App is an App that Enables user to Upload and Review Images (Contributions) through their Android Devices. The goal of this GSOC Project is to Migrate the project from RxJava to Kotlin Coroutines and Flows.

As our project continues to evolve, leveraging the most efficient and modern technologies is imperative for maintaining our competitive edge and optimizing our development process. Kotlin Coroutines offers a contemporary approach to asynchronous programming, aligning with our goal to adopt modern, concise, and efficient codebases.
As Also Suggested Here RxJava2 is "end of life" , and the optimal path for this project should be to directly migrate to Kotlin Coroutines and Flows Instead.

Have you contacted your mentors already?

Yes

Deliverables

There are Main Three Divisions of this Project:
1. Migration from RxJava to Kotlin Coroutines & Flows
2. Split Nearby into a fast query for coordinates + a details query for each pin #4560
3. Report that a Nearby item is not at the specified location #2425

Implementation Strategy

Migration from RxJava to Kotlin Coroutines & Flows

migrationRxJava.png (3×2 px, 239 KB)

The discussion here provides a very good overall Idea as to what needs to be done for this migration, I am using this information and my own analysis of the project to construct the following Implementation strategy:

Here is how I plan to Implement this Migration :
1. Code Analysis & Planning
Planning the migration, identifying parts of the code to convert, and mapping RxJava patterns to Coroutines/Flow equivalents

2. Java to Kotlin Conversion
This could be partly automated using Android Studio's conversion tool, but manual adjustments and review will be necessary.

3. Migration of RxJava Constructs to Kotlin Coroutines/Flow

  1. 1. PublishSubject to SharedFlow
  2. 2. BehaviorSubject to StateFlow
  3. 3. Completable to Suspend - 8 files in production, 3 in tests.
  4. 4. Single to Suspend Function - 41 files in production, 32 in tests.
  5. 5. Observable Cases - 44 files in production, 18 in tests. These require a case-by-case analysis to determine whether to use collecting a Flow or converting to a suspend function.
Split Nearby into a fast query for coordinates + a details query for each pin #4560

The current problem is that when users access the Nearby feature, especially in dense urban areas, the app attempts to load a comprehensive dataset for each POI(Points of Interest), including detailed information like name, description, class, and existence. This process is based on a single SPARQL request that fetches all these details simultaneously. Given the large number of POIs in such areas, this request becomes exceedingly complex and time-consuming, leading to long loading times or even timeouts.

As also suggested in the Issue description itself we have to divide the data retrieval process into two distinct phases - Fast Query for Coordinates and then a second query separate asynchronous requests for each pin to fetch the detailed information.

The following needs to be done to implement this:

  • Designing a Simplified SPARQL Query For Initial Coordinates Retrieval and Separate queries for detailed Information. I think we already have a pretty good query for this here
  • Asynchronous Loading Strategy for separate queries
  • Implement the simplified query to fetch and display basic POI data quickly.
  • Develop the logic for asynchronously fetching detailed POI information, including error handling and performance optimization.
  • Fine-tune the asynchronous detail retrieval process, possibly by batching requests or prioritizing visible pins. (as suggested here )
  • Test the new implementation in various scenarios, especially in densely populated areas, to assess improvements.
Report that Nearby item is not at specified location #2425

As Suggested here possible solutions Include adding a "Report" Button.

  • Implement a "Report" that lets the user report the point and gives them the ability to choose from the following:
    1. The item is not found around that point
    2. The point is a bit further
    3. The item does not exist anymore at that place

Timeline

PeriodTask Description
May 4 to May 26Community bonding period- Join community and connect with Mentors
- Introduction and connecting with other contributors
- Start Code Analysis and Identify what part of the code needs migration
- Create a Report on what code parts are going to be migrated from RxJava and also what are necessary Java to Kotlin Migrations Required
- Start on Java to Kotlin Migration for required files
May 27 to May 31- Refractor and Review and Test after Java to Kotlin Migration
May 31 to June 2- Finalise migration strategy and take feedback from mentors and contributors
June 2 to June 4- Start RxJva Migration: PublishSubject to SharedFlow, and write tests
June 4 to June 8- BehaviorSubject to StateFlow, write corresponding tests
June 8 to June 16- Completable to Suspend , write corresponding tests
June 16 to July 8-Single to Suspend Function , and write corresponding tests
July 8 to July 12Mid Term Evaluations- Code Cleanup, Testing and Progress Report/Blog
July 13 to August 1- Migration of Observable , and write corresponding tests
August 1 to August 8- Report that Nearby item is not at specified location #965
August 8 to August 18- Split Nearby into a fast query for coordinates + a details query for each pin: #4560
August 18 to September 22- Finalise Changes , Code Quality Review and Improvements
August 22 to September 26- Update Documentation for changes, Write and Submit Report/Blog for all the Tasks Completed and Accomplishments, Learnings
August 26 to September 2Final Evaluations- Mentors submit final GSoC contributor evaluations

Participation

  • I plan to communicate through GitHub, Zulip, and any other suggested mediums
  • I plan to report the successful completion of tasks through detailed blogs on either Hashnode or Medium
  • I am available online during my working hours and I am always available on my Email.
  • I am also available during my working hours for Online meetings through Google Meet or Other Mediums if required.

Previous Contributions to Commons

I started Contributing to Commons in December 2023 and have made several pull requests since then. You can look at those here

Pull Requests Created By Me

Total : 33 :: BUGs : 16 Enhancements: 8 Migrations: 9
Merged: 31
Open: 4

S.No.PR No.Issue No.DescriptionStatus
1PR #5544#5522BUG Precise error message if the password has become invalid after password changeMerged
2PR #5466#5437BUG Crash in Upload Wizard when changing Android font sizeMerged
3PR #5618#5277Custom picker: Show different pictures that are currently being uploadedMerged
4PR #5468#5448BUG Nearby banner shows Item without imageMerged
5PR #5576#5558Do not reload everything after marking a picture as not for uploadMerged
6PR #5500#5474BUG App Crashes when Switched Between Dark/Light Mode in Location Picker ActivityMerged
7PR #5510#5505BUG Edit Category Crashes when Previous Button is ClickedMerged
8PR #5525#5521BUG Methods Usage Incompatible with Android API Level 21Merged
9PR #5590#4664Migrate Upload Package To View Binding from ButterknifeMerged
10PR #5503#5473BUG Changes Lost and App Crashes when Switched between Dark-Light Modes in Edit Description and CaptionsMerged
11PR #5665#4611Make custom image selector available from NearbyMerged
12PR #5655#5556[Bug]: Set Wallpaper Not Working CorrectlyMerged
13PR #5636#5630Option to Remove Specific Images from Upload WizardMerged
14PR #5594#4664Migrated Bookmarks Package From Butterknife to ViewBindingMerged
15PR #5601#4664Migrated Media Package to View BindingMerged
16PR #5595#4664Migrated CategoryDetailsActivity , MainActivity to View BindingMerged
17PR #5593#4664Migrated Contributions Package From Butterknife to ViewBindingMerged
18PR #5592#4664Migrated Explore Package From Butterknife to ViewBindingMerged
19PR #5591#4664Migrated Profile Package from Butterknife to View BindingMerged
20PR #5478#5477BUG Selected 18 pictures for multi-upload, but Upload Wizard only asks metadata for 1 pictureMerged
21PR #5550#5547BUG App Crashes after clicking on Explore in bottom NavigationMerged
22PR #5543#5537BUG Unable to upload DNG / RAW imagesMerged
23PR #5492#5470Show Details About Icon Labels when long pressedMerged
24PR #5493#5470Show Details About Icon Labels when long pressedMerged
25PR #5534#5532BUG Can't Open Privacy PolicyMerged
26PR #5604#4664Migrated Review Package to View BindingMerged
27PR #5519#5516BUG Peer Review Buttons not get disabled after voting an Image for deletionMerged
28PR #5660#4664Remove Butterknife from Project & Complete Migration from ButterknideMerged
29PR #5640#5627BUG Custom picker: thumbnails sometimes blankMerged
30PR #5639#5628BUG Custom picker sometimes crashing when marking many pictures as "not for upload" towards the bottomMerged
31PR #5648#5644BUG Fix Custom picker: "uploading" overlay icon disappears when marking another pic as "not for upload"Merged
32PR #5643#5642BUG No Precise Error Message After Error Due to Password ChangeOpen

Issues Created By Me

S.No.Issue No.DescriptionStatusType
1#5547App Crashes after clicking on Explore in bottom NavigationClosedBUG
2#5521Methods Usage Incompatible with Android API Level 21 (Target SDK Version)ClosedBUG
3#5505Edit Category Crashes when Previous Button is ClickedClosedBUG
4#5474App Crashes when Switched Between Dark/Light Mode in Location Picker ActivityClosedBUG
5#5532Can't Open Privacy PolicyClosedBUG
6#5516Peer Review Buttons are not disabled while the next image is Loading After Nominating it for deletionClosedBUG
7#5473Changes Lost and App Crashes when Switched between Dark-Light Modes in Edit Description and CaptionsClosedBUG
8#5630Option to Remove Specific Images from Upload WizardClosedEnhancement
9#5470Show Details About Icon Labels when long pressedClosedEnhancement
10#5642No Precise Error Message After Error Due to Password ChangeOpenEnhancement

PR Reviews By Me:

  1. Reviewed Pull Request #5575 and made this[[ https://github.com/commons-app/apps-android-commons/pull/5575#pullrequestreview-1911563193 | Comment ]]
  2. Review Pull Request #5578 and added some suggestions.

About Me

I am Shashank Kumar, a Sophomore at the Indian Institute of Technology (BHU), Varanasi, pursuing a B.Tech in Pharmaceutical Engineering & Technology. I have been programming since I was 12 and I have an immense love for building products and solving problems through programming.

How did you hear about this program?

I got to know about this program from a fellow developer at the farewell event of Google's Appscale Academy.

We advise all candidates eligible for Google Summer of Code and Outreachy to apply for both programs. Are you planning to apply to both programs and, if so, with what organization(s)?

I am only applying to Google Summer of Code.

Past Experience

I have been coding since I was 12 and I have been working in Java since then and even got certified as Oracle Certified Associate, Java SE 8 Programmer at 13. My Journey to Android App development started soon after and even became Google Certified Associate Android Developer at 14. I have been developing Android Apps since then and I have worked on a few Android app projects since then, a notable one which I made when I was in High School Android-Java Tutorial App which got more than 35000 Installs on Play Store.

One of the main Android App I built for - Opined, which is a Social Media Platform that I founded and where I handled all the tech ( Web and Backend in PHP - Laravel ) and
The Android App - Opined App :

  • Opined is an Anonymous Social Media Platform that eliminates the problem of biases created by personalization algorithms
  • The app is Built on Java and Kotlin/Jetpack Compose
  • Uses Sentiment Analysis to Rank User's Opinions
  • Fetches Latest News & Headlines and allows users to put their opinions on them
  • Got More than 10000 Installs on the Play Store
  • Got Selected in the 2022 Batch of Google Appscale Academy

Relevant Skills

  • Android App Development with Java and Kotlin
  • Jetpack Compose
  • Git and GitHub
  • Retrofit and REST APIs
  • Room Database and SQL
  • Unit Testing and Understanding of Robolectric
  • RxJava and Multi-Threading
  • Understanding of Wikimedia's APIs

Volunteer Experience

  • Core Team Member of Club of Programmers (Software Development Group), IIT (BHU) Varanasi
  • Backend Lead at Tech Team of Training and Placement Cell, IIT (BHU) Varanasi

Availability

Are you eligible for Google Summer of Code?

Yes.

Do you plan to submit any other proposal apart from this one?

Yes, I am also submitting this proposal

Do you have any other plans during the period of GSoC?

No, I do not have any other plans during the contribution period.

How many hours per week can you dedicate to this?

I can devote at least 40 hours per week and can extend it further if needed, I will have no major commitments during this period, and because of my end-of-semester breaks I won't have any academic commitments during this period either.

Have you been accepted to GSoC before?

No. I am applying to the GSoC program for the first time.

Post GSOC :

I like this project personally and I love how active and enthusiastic the whole contributors community in Commons Android. This community is something that I want to be part of for a long time and keep contributing to and improving this project even after GSOC and I'll be more than happy to be a part of major changes in this project. I have tons of ideas for this project and would love to discuss and implement those over a long period.

Event Timeline

@Nicolas_Raoul @RitikaPahwa4444 Can You Please Review this Proposal? I am looking forward to your feedback on this

As we discussed via email beforehand, to me this seems to be a reasonable project content for a GSoC.

Just a few minor comments on the project description:

Migration from RxJava to

I think the title here seems to have been truncated.

  1. Report that a Nearby item is not at the specified location #965

The issue #965 seems closed. Could you possibly also link to the relevant issue that is currently open?

The nearby feature improvement sounds nice and is expected to be faster. Can you include measurement to check how much faster it turns out to be into the plan? Would it be outside of the scope of GSOC?

I'm thinking of someone going to an urban area with a physical phone, and compare the response time before/after. Depending on where you are, the need to travel might make it difficult, but if it's not too difficult, it would be great to be able to see the impact in an objective way.

@whym:
Apps like Fake GPS allow us to perform tests in places with many pins such as Paris, or places with few pins such as deserts. :-)
I would suggest taking screencasts of Wikishootme and the app for the same area and zoom level, then compare the time until all pins are loaded.