Skip to content

Fixes #3790- Use WorkManagers to upload contributions #4298

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

Merged
merged 12 commits into from
Apr 8, 2021

Conversation

ashishkumar468
Copy link
Collaborator

@ashishkumar468 ashishkumar468 commented Mar 21, 2021

Description (required)

Fixes #3790

What changes did you make and why?
Use WorkManagers to process upload contributions
** Removed UploadService and Added UploadWorker to process contributions Upload
** Made necessary changes to remove the usages of the Service from the classes
** UI Fixes- Minor changes in the retry and cancel upload icons to give them a clickable area of 48 dp

Tests performed (required)

Tested betaDebug on Pixel 4A- API 30
Tested all possible happy cases for the following

  • Single file upload
  • Multi-File Upload
  • Nearby Upload - Wikidata happens
  • Limited Connection Mode - ON/OFF
  • Test Pause/Resume Uploads

Use WorkManagers to process upload contributions
** Removed UploadService and Added UploadWorker to process contributions Upload
** Made nescessary changes to remove the usages of the Service from the classes
** UI Fxies- Minor changes in the retry and cancel uplaod icons to give them a clickable area of 48 dp
app/build.gradle Outdated
}

android {
compileSdkVersion 28
compileSdkVersion 29
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is recommended now

@@ -135,8 +135,7 @@
android:name=".review.ReviewActivity"
android:label="@string/title_activity_review" />

<service android:name=".upload.UploadService" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleted the service

Use WorkManagers to process upload contributions
** Removed UploadService and Added UploadWorker to process contributions Upload
** Made nescessary changes to remove the usages of the Service from the classes
** UI Fxies- Minor changes in the retry and cancel uplaod icons to give them a clickable area of 48 dp
@neslihanturan
Copy link
Collaborator

neslihanturan commented Mar 23, 2021

Hi @ashishkumar468 , I have made a few tests on this PR. All tests are made on beta debug with a fresh install:

  • Upload from gallery:
    • Upload has started as always, however it was very slow.
    • According to the progress bar upload finished.
    • But even progress bar finishes with no error, upload has not made.
    • File is not uploaded and there is no thumbnail on contrib list. Only placeholder.
  • Upload from camera:
    • Upload again was very slow.
    • It failed once, I retried with retry button.
    • The rest is same with the flow for gallery.
      Here are how contrib list was looking like after my these 2 attempt:

After that I went to master branch. The missing two uploads have been made right after I compiled master branch (since there is a file as "kedi" it is renamed to "kedi4", since there is a file as "flower" it is renamed to "flower2") and they are added to contributions list. However, the items at contributions list from my previous upload attempt (unsuccessful uploads, only placeholder is displayed) stayed remain on the list. Here how contributions list is appeared when I switch to master branch:

@ashishkumar468
Copy link
Collaborator Author

Hi @neslihanturan, can you share the logs from when the uploads don't happen

@neslihanturan
Copy link
Collaborator

Sure, would this one work?

21-03-23 18:10:07.528 20595-31791/fr.free.nrw.commons.beta E/ContributionBoundaryCallback$fetchContributions: Failed to fetch contributions: closed
2021-03-23 18:10:07.572 20595-31790/fr.free.nrw.commons.beta E/OkHttpConnectionFactory$UnsuccessfulResponseInterceptor: java.io.IOException: {"error":{"code":"urlparamnormal","info":"Could not normalize image parameters for LastTest-_-_1.jpeg.","docref":"See https://commons.wikimedia.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes."},"servedby":"deployment-mediawiki-07"}
        at fr.free.nrw.commons.OkHttpConnectionFactory$UnsuccessfulResponseInterceptor.intercept(OkHttpConnectionFactory.java:90)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:225)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
        at okhttp3.RealCall.execute(RealCall.java:92)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:190)
        at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:42)
        at io.reactivex.Observable.subscribe(Observable.java:12267)
        at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
        at io.reactivex.Observable.subscribe(Observable.java:12267)
        at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleFlatMap.subscribeActual(SingleFlatMap.java:36)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
        at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
        at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
        at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
2021-03-23 18:10:07.572 20595-31790/fr.free.nrw.commons.beta D/OkHttp: <-- 200 https://commons.wikimedia.beta.wmflabs.org/w/api.php?action=query&format=json&formatversion=2&generator=allimages&gaisort=timestamp&gaidir=older&prop=imageinfo&iiprop=url|extmetadata|user&&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&gaiuser=Neslihan%20Test&gailimit=10&gaicontinue=20180701192418|Tst_4.jpg&continue=gaicontinue|| (417ms, unknown-length body)
2021-03-23 18:10:07.574 20595-31790/fr.free.nrw.commons.beta E/ContributionBoundaryCallback$fetchContributions: Failed to fetch contributions: closed
2021-03-23 18:10:07.624 20595-31811/fr.free.nrw.commons.beta D/OkHttp: --> GET https://commons.wikimedia.beta.wmflabs.org/w/api.php?action=query&format=json&formatversion=2&generator=allimages&gaisort=timestamp&gaidir=older&prop=imageinfo&iiprop=url|extmetadata|user&&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&gaiuser=Neslihan%20Test&gailimit=10&gaicontinue=20180701192418|Tst_4.jpg&continue=gaicontinue||
2021-03-23 18:10:07.627 20595-31811/fr.free.nrw.commons.beta D/CookieManager: Domain:commons.wikimedia.beta.wmflabs.org
2021-03-23 18:10:07.717 20595-32008/fr.free.nrw.commons.beta E/OkHttpConnectionFactory$UnsuccessfulResponseInterceptor: java.io.IOException: {"error":{"code":"urlparamnormal","info":"Could not normalize image parameters for LastTest-_-_1.jpeg.","docref":"See https://commons.wikimedia.beta.wmflabs.org/w/api.php for API usage. Subscribe to the mediawiki-api-announce mailing list at &lt;https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce&gt; for notice of API deprecations and breaking changes."},"servedby":"deployment-mediawiki-07"}
        at fr.free.nrw.commons.OkHttpConnectionFactory$UnsuccessfulResponseInterceptor.intercept(OkHttpConnectionFactory.java:90)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:225)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
        at okhttp3.RealCall.execute(RealCall.java:92)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:190)
        at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:42)
        at io.reactivex.Observable.subscribe(Observable.java:12267)
        at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34)
        at io.reactivex.Observable.subscribe(Observable.java:12267)
        at io.reactivex.internal.operators.observable.ObservableSingleSingle.subscribeActual(ObservableSingleSingle.java:35)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleFlatMap.subscribeActual(SingleFlatMap.java:36)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleMap.subscribeActual(SingleMap.java:34)
        at io.reactivex.Single.subscribe(Single.java:3603)
        at io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89)
        at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:578)
        at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
        at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)
        ```

@ashishkumar468
Copy link
Collaborator Author

Hi @neslihanturan Thanks for sharing the logs, I am looking into it

@ashishkumar468
Copy link
Collaborator Author

Hi @neslihanturan , I have updated the PR with a fix, verified the upload on Android 10, could you re-verify please?

@neslihanturan
Copy link
Collaborator

Hey @ashishkumar468 , thanks for the fixes. Now upload succeeded but after select the image I have just uploaded to see media details, it crashed with error:

-03-31 22:34:20.084 2178-2178/com.android.systemui D/StatusBar: disable<e i a s b h!r!c s > disable2<q i n >
2021-03-31 22:34:20.085 1133-1288/system_process W/UsageStatsService: Event reported without a package name, eventType:18
2021-03-31 22:34:20.089 2178-2178/com.android.systemui D/KeyguardUpdateMonitor: onKeyguardVisibilityChanged(false)
2021-03-31 22:34:20.397 2178-2178/com.android.systemui D/ImageWallpaper: wallpaper visibility changes to: false
2021-03-31 22:34:20.584 2149-8607/fr.free.nrw.commons.beta D/OkHttp: <-- 200 https://commons.wikimedia.beta.wmflabs.org/w/api.php?format=json&formatversion=2&errorformat=plaintext&action=query&meta=notifications&notformat=model&notlimit=max&notwikis=wikidatawiki%7Ccommonswiki%7Cenwiki&notfilter=%21read (544ms, unknown-length body)
2021-03-31 22:34:20.615 2149-2149/fr.free.nrw.commons.beta D/ContributionsFragment: Number of notifications is 8
2021-03-31 22:34:21.086 2178-2406/com.android.systemui D/ImageWallpaper: finishRendering, preserve=false
2021-03-31 22:34:21.469 2149-2149/fr.free.nrw.commons.beta D/AndroidRuntime: Shutting down VM
    
    
    --------- beginning of crash
2021-03-31 22:34:21.471 2149-2149/fr.free.nrw.commons.beta E/AndroidRuntime: FATAL EXCEPTION: main
    Process: fr.free.nrw.commons.beta, PID: 2149
    android.database.sqlite.SQLiteException: Can't downgrade database from version 15 to 14
        at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:541)
        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:415)
        at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:341)
        at fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesContentProvider.query(BookmarkPicturesContentProvider.java:61)
        at android.content.ContentProvider.query(ContentProvider.java:1214)
        at android.content.ContentProvider.query(ContentProvider.java:1307)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:267)
        at android.content.ContentProviderClient.query(ContentProviderClient.java:195)
        at android.content.ContentProviderClient.query(ContentProviderClient.java:177)
        at android.content.ContentProviderClient.query(ContentProviderClient.java:167)
        at fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao.findBookmark(BookmarkPicturesDao.java:132)
        at fr.free.nrw.commons.media.MediaDetailPagerFragment.updateBookmarkState(MediaDetailPagerFragment.java:318)
        at fr.free.nrw.commons.media.MediaDetailPagerFragment.onCreateOptionsMenu(MediaDetailPagerFragment.java:273)
        at androidx.fragment.app.Fragment.performCreateOptionsMenu(Fragment.java:2808)
        at androidx.fragment.app.FragmentManager.dispatchCreateOptionsMenu(FragmentManager.java:2664)
        at androidx.fragment.app.Fragment.performCreateOptionsMenu(Fragment.java:2810)
        at androidx.fragment.app.FragmentManager.dispatchCreateOptionsMenu(FragmentManager.java:2664)
        at androidx.fragment.app.FragmentController.dispatchCreateOptionsMenu(FragmentController.java:387)
        at androidx.fragment.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:325)
        at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:94)
        at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.onCreatePanelMenu(AppCompatDelegateImpl.java:2830)
        at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:94)
        at androidx.appcompat.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:455)
        at androidx.appcompat.app.ToolbarActionBar$1.run(ToolbarActionBar.java:56)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:967)
        at android.view.Choreographer.doCallbacks(Choreographer.java:791)
        at android.view.Choreographer.doFrame(Choreographer.java:722)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
2021-03-31 22:34:21.472 2149-2149/fr.free.nrw.commons.beta E/ACRA: ACRA caught a SQLiteException for fr.free.nrw.commons.beta
    android.database.sqlite.SQLiteException: Can't downgrade database from version 15 to 14
        at android.database.sqlite.SQLiteOpenHelper.onDowngrade(SQLiteOpenHelper.java:541)
        at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:415)
        at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:341)
        at fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesContentProvider.query(BookmarkPicturesContentProvider.java:61)
        at android.content.ContentProvider.query(ContentProvider.java:1214)
        at android.content.ContentProvider.query(ContentProvider.java:1307)
        at android.content.ContentProvider$Transport.query(ContentProvider.java:267)
        at android.content.ContentProviderClient.query(ContentProviderClient.java:195)
        at android.content.ContentProviderClient.query(ContentProviderClient.java:177)
        at android.content.ContentProviderClient.query(ContentProviderClient.java:167)
        at fr.free.nrw.commons.bookmarks.pictures.BookmarkPicturesDao.findBookmark(BookmarkPicturesDao.java:132)
        at fr.free.nrw.commons.media.MediaDetailPagerFragment.updateBookmarkState(MediaDetailPagerFragment.java:318)
        at fr.free.nrw.commons.media.MediaDetailPagerFragment.onCreateOptionsMenu(MediaDetailPagerFragment.java:273)
        at androidx.fragment.app.Fragment.performCreateOptionsMenu(Fragment.java:2808)
        at androidx.fragment.app.FragmentManager.dispatchCreateOptionsMenu(FragmentManager.java:2664)
        at androidx.fragment.app.Fragment.performCreateOptionsMenu(Fragment.java:2810)
        at androidx.fragment.app.FragmentManager.dispatchCreateOptionsMenu(FragmentManager.java:2664)
        at androidx.fragment.app.FragmentController.dispatchCreateOptionsMenu(FragmentController.java:387)
        at androidx.fragment.app.FragmentActivity.onCreatePanelMenu(FragmentActivity.java:325)
        at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:94)
        at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.onCreatePanelMenu(AppCompatDelegateImpl.java:2830)
        at androidx.appcompat.view.WindowCallbackWrapper.onCreatePanelMenu(WindowCallbackWrapper.java:94)
        at androidx.appcompat.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:455)
        at androidx.appcompat.app.ToolbarActionBar$1.run(ToolbarActionBar.java:56)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:967)
        at android.view.Choreographer.doCallbacks(Choreographer.java:791)
        at android.view.Choreographer.doFrame(Choreographer.java:722)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940)
2021-03-31 22:34:21.544 1133-3058/system_process I/ActivityTaskManager: START u0 {flg=0x10000000 cmp=fr.free.nrw.commons.beta/org.acra.dialog.CrashReportDialog (has extras)} from uid 10154
2021-03-31 22:34:21.553 2149-2149/fr.free.nrw.commons.beta I/Process: Sending signal. PID: 2149 SIG: 9
2021-03-31 22:34:21.682 1133-1989/system_process W/InputDispatcher: channel '280d321 fr.free.nrw.commons.beta/fr.free.nrw.commons.contributions.MainActivity (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
2021-03-31 22:34:21.682 1133-1989/system_process E/InputDispatcher: channel '280d321 fr.free.nrw.commons.beta/fr.free.nrw.commons.contributions.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2021-03-31 22:34:21.684 1133-8674/system_process I/ActivityManager: Process fr.free.nrw.commons.beta (pid 2149) has died: fore TOP 
2021-03-31 22:34:21.689 1133-3058/system_process I/WindowManager: WIN DEATH: Windo

Copy link
Collaborator

@neslihanturan neslihanturan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ashishkumar468 , it works. Will merge right after conflicts are fixed :)

@ashishkumar468
Copy link
Collaborator Author

Hi @neslihanturan , @misaochan - I have updated the PR, synced it with the master branch to resolve merge conflicts. Please have a look.

Copy link
Collaborator

@neslihanturan neslihanturan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @ashishkumar468 :)

@neslihanturan neslihanturan merged commit ecbff7e into commons-app:master Apr 8, 2021
@ashishkumar468 ashishkumar468 deleted the work-manager branch May 2, 2021 04:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch to WorkManagers
2 participants