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

[Bug]: Category search times out or returns nothing.

Open adambuchbinder opened this issue 1 year ago • 12 comments

Summary

In the upload flow, the Category search does not bring anything up, regardless of the search text entered. There's no error message either.

Steps to reproduce

  1. Open the app.
  2. Upload a picture.
  3. At the Category page, enter some search text.
  4. Wait.

Expected behaviour

Some categories should appear as options.

Actual behaviour

The list of categories is blank.

Device name

Google Pixel 5a

Android version

Android 14

Commons app version

4.2.1~14b6c455b

Device logs

No response

Screen-shots

No response

Would you like to work on the issue?

Prefer not

adambuchbinder avatar Mar 12 '24 23:03 adambuchbinder

Hey @adambuchbinder, Thank you for reporting the issue.

I tested it on my device and on version 4.2.1~14b6c455b. It is working fine for me.

https://github.com/commons-app/apps-android-commons/assets/114223204/ccaf56d8-50ae-483e-bd53-482b334c5ca5

kanahia1 avatar Mar 13 '24 04:03 kanahia1

@adambuchbinder Does that always happen, or just sometimes?

nicolas-raoul avatar Mar 13 '24 06:03 nicolas-raoul

I also experienced this several days before and thought it might be due to the unavailability of categories for some text. However, I did not recall for which text the category was blank in my case. @adambuchbinder can you tell us which category you searched for?

rohit9625 avatar Mar 13 '24 07:03 rohit9625

It doesn't matter what I search for; nothing shows up in the category box. See the video. (Too large to attach, on mobile so can't reencode.)

https://photos.app.goo.gl/q7fP7nqLyNG79Y3RA

adambuchbinder avatar Mar 14 '24 16:03 adambuchbinder

When a technical error happens here we should display a snackbar with the message.

Even when the reason is that there is no internet, we do not show any error message:

https://github.com/commons-app/apps-android-commons/assets/99590/f606cd98-d33e-4f0d-8206-e2a327c29528

nicolas-raoul avatar Mar 15 '24 01:03 nicolas-raoul

When a technical error happens here we should display a snackbar with the message.

Even when the reason is that there is no internet, we do not show any error

What is the cause that categories are not being fetched? Did you find anything in the logs?

rohit9625 avatar Mar 16 '24 02:03 rohit9625

Sorry, I'm not familiar with some of the workflows here. How do I look at the logs to find out why categories aren't being fetched?

adambuchbinder avatar Mar 18 '24 17:03 adambuchbinder

How do I look at the logs to find out why categories aren't being fetched?

@adambuchbinder in main menu, Settings, Send log file you can get the logs.

mnalis avatar Apr 13 '24 18:04 mnalis

Thank you for your patience; here's what looks like the relevant log.


2024-04-12 01:45:17,107     [ERROR] [file-logging-thread-1] [CategoriesPresenter$onAttachView] : android.database.sqlite.SQLiteException: no such column: description (code 1 SQLITE_ERROR): , while compiling: SELECT _id, name, description, thumbnail, last_used, times_used FROM categories ORDER BY last_used DESC
	at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
	at android.database.sqlite.SQLiteConnection.-$$Nest$smnativePrepareStatement(Unknown Source:0)
	at android.database.sqlite.SQLiteConnection$PreparedStatementCache.createStatement(SQLiteConnection.java:1562)
	at android.database.sqlite.SQLiteConnection.acquirePreparedStatementLI(SQLiteConnection.java:1098)
	at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1126)
	at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:686)
	at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:614)
	at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:62)
	at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:37)
	at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:46)
	at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1818)
	at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:601)
	at android.database.sqlite.SQLiteQueryBuilder.query(SQLiteQueryBuilder.java:472)
	at fr.free.nrw.commons.category.CategoryContentProvider.query(CategoryContentProvider.java:61)
	at android.content.ContentProvider.query(ContentProvider.java:1620)
	at android.content.ContentProvider.query(ContentProvider.java:1716)
	at android.content.ContentProvider$Transport.query(ContentProvider.java:295)
	at android.content.ContentProviderClient.query(ContentProviderClient.java:196)
	at android.content.ContentProviderClient.query(ContentProviderClient.java:178)
	at android.content.ContentProviderClient.query(ContentProviderClient.java:168)
	at fr.free.nrw.commons.category.CategoryDao.recentCategories(CategoryDao.java:87)
	at fr.free.nrw.commons.category.CategoriesModel.suggestionsOrSearch(CategoriesModel.kt:96)
	at fr.free.nrw.commons.category.CategoriesModel.searchAll(CategoriesModel.kt:82)
	at fr.free.nrw.commons.repository.UploadRepository.searchAll(UploadRepository.java:124)
	at fr.free.nrw.commons.upload.categories.CategoriesPresenter.searchResults(CategoriesPresenter.kt:89)
	at fr.free.nrw.commons.upload.categories.CategoriesPresenter.access$searchResults(CategoriesPresenter.kt:27)
	at fr.free.nrw.commons.upload.categories.CategoriesPresenter$onAttachView$2.invoke(CategoriesPresenter.kt:61)
	at fr.free.nrw.commons.upload.categories.CategoriesPresenter$onAttachView$2.invoke(CategoriesPresenter.kt:61)
	at fr.free.nrw.commons.upload.categories.CategoriesPresenter.onAttachView$lambda$1(CategoriesPresenter.kt:61)
	at fr.free.nrw.commons.upload.categories.CategoriesPresenter.$r8$lambda$V9nJs5XN8YTx1bOUFgkxBKeDtrk(CategoriesPresenter.kt:0)
	at fr.free.nrw.commons.upload.categories.CategoriesPresenter$$ExternalSyntheticLambda10.apply(R8$$SyntheticClass:0)
	at io.reactivex.internal.operators.observable.ObservableSwitchMap$SwitchMapObserver.onNext(ObservableSwitchMap.java:111)
	at io.reactivex.internal.operators.observable.ObservableDoOnEach$DoOnEachObserver.onNext(ObservableDoOnEach.java:101)
	at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:201)
	at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:255)
	at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
	at android.os.Handler.handleCallback(Handler.java:959)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loopOnce(Looper.java:232)
	at android.os.Looper.loop(Looper.java:317)
	at android.app.ActivityThread.main(ActivityThread.java:8592)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)

I've attached the full log: CommonsAppLogs.0.txt

adambuchbinder avatar Apr 13 '24 20:04 adambuchbinder

Interesting . That ERROR:

[CategoriesPresenter$onAttachView] : android.database.sqlite.SQLiteException: 
no such column: description (code 1 SQLITE_ERROR): , while compiling: 
SELECT _id, name, description, thumbnail, last_used, times_used FROM categories ORDER BY last_used DESC

sounds like there are columns missing from internal SQL database. That should not happen normally (or the app wouldn't be working for anyone if such bug made it to the release). I'm not very familiar for code there, but I had to hazard a guess, I would guess that there was some previous version of Commons app installed before, and that upgrade to newer version didn't quite work, leaving the database out of sync with the app.

If that guess is correct, then uninstalling (which will remove local database) and installing Commons app again (which will recreate it) should fix the issue. (provided you don't have some kind of os-based backup-app-data-to-cloud-and-restore-it-automagically-on-reinstall shenanigans enabled; in which case this might work instead: Android OS settings / Apps / Commons / Storage / Clear data). Would you be willing to try that @adambuchbinder ?

(full log also shows a case of badinteger / missingtitle ERRORS, but according to https://github.com/commons-app/apps-android-commons/issues/5244 those are benign and may be ignored)

mnalis avatar Apr 13 '24 21:04 mnalis

@nicolas-raoul, Should we add how to get logs in readme.md file so that non-technical people can easily get through this.

kanahia1 avatar Apr 14 '24 06:04 kanahia1

You're right; clearing the app data fixed it. Thanks! (This actually persisted across a phone migration, which... thanks?)

adambuchbinder avatar Apr 14 '24 16:04 adambuchbinder