bubelov / news

Feed Reader and Podcast Player for Android
https://f-droid.org/packages/co.appreactor.news/
GNU General Public License v3.0
408 stars 25 forks source link

Fix crashes while scrolling the news feed #68

Open Happyfeet01 opened 3 years ago

Happyfeet01 commented 3 years ago

Hello,

when i read the news and scrolling down, the App Force Close.

Nextcloud 21.02 latest News Reader from F-Droid Store

exception logs:

https://paste.dasnetzundich.de/view/c2632621

bubelov commented 3 years ago

@Happyfeet01 This one is tricky to find but pretty harmless. I'll try to fix it in the next release. Does it happen often?

java.lang.Exception: Can't sync opened news
        at sync.NewsApiSync.sync(NewsApiSync.kt:86)
        at sync.NewsApiSync$sync$1.invokeSuspend(Unknown Source:12)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
        at android.os.Handler.handleCallback(Handler.java:900)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at android.os.Looper.loop(Looper.java:219)
        at android.app.ActivityThread.main(ActivityThread.java:8387)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1055)
Caused by: kotlinx.coroutines.JobCancellationException: Job was cancelled; job=SupervisorJobImpl{Cancelling}@dbe59d3
Happyfeet01 commented 3 years ago

Yes, every time when i scroll down

bubelov commented 3 years ago

@Happyfeet01 are you using default settings? If not, you can send me the screenshot of settings screen so I will be able to reproduce your issue. You can also try to reinstall the app or simply log out and log in, it should reset everything. Enabling custom settings one-by-one might also help to pin down the issue.

If nothing helps, I think F-Droid allows users to choose the app version. You can install the older version for now.

Happyfeet01 commented 3 years ago

Screenshot_20210526_133236_co appreactor news

bubelov commented 3 years ago

@Happyfeet01 you can try to turn off "Mark scrolled as read", maybe it will help

p-fruck commented 2 years ago

@bubelov What is the current state of this issue? I was using the debug build you provided in #16 until recently, which worked just fine (even with mark scrolled entries enabled). After the issue with the app crashing on android 12 was fixed, I updated to the official version of news and I now experience the same issue where the app stops running when scrolling down or opening a feed. Even with mark scrolled as read disabled, the app force closes sometimes when opening a feed item. Might this behavior be related to this issue, or should I open a new one? Also, is there a built-in option to retrieve the logs? Running news version 0.3.1 from Fdroid on Android 12 without google services

bubelov commented 2 years ago

@p-fruck did you try to delete the old app and make a clean install? 0.3 might be incompatible with 0.2

bubelov commented 2 years ago

@p-fruck also, see https://github.com/bubelov/news/issues/93 if you're using NC. Apparently, SSO library is quite unpredictable, so I had to bring manual NC login as a top-level option. It's not yet available in F-Droid, but it helps some users with sync issues

p-fruck commented 2 years ago

@bubelov thanks for the quick response. I uninstalled the debug build and did a fresh install of news v0.3.1 with clean storage, but the issue persists. I also downgraded my nextcloud app which I use for SSO to 3.17.1 as you mentioned, but still no success. Unfortunately, SSO is kind of a requirement for me, I'm also not sure if this really is the error here, since as I mentioned it worked fine with your previous debug build. Maybe it is also a bug with the new app theme on android 12? I'm not really into android development, can you tell me a rootless way to retrieve the logs of the app? :D

p-fruck commented 2 years ago

Also, v0.3.1 using SSO with nextcloud 3.18.0 on android 10 (with google services, in case this matters) has been confirmed to work without such crashes

bubelov commented 2 years ago

@p-fruck so you can see the news, but when you try to scroll, it crashes? Can you try switching to standalone mode and adding any feed with it? If it will work, it probably has something to do with NC SSO. If it still crashes, at least we'll know its caused by something else

Happyfeet01 commented 2 years ago

@p-fruck so you can see the news, but when you try to scroll, it crashes? Can you try switching to standalone mode and adding any feed with it? If it will work, it probably has something to do with NC SSO. If it still crashes, at least we'll know its caused by something else

I using the latest stable build f-droid. No crashes.

p-fruck commented 2 years ago

@bubelov You're right, in standalone mode I do not experience any issues. When using NC SSO, scrolling the news feed works fine but opening a specific article force closes the app (happens every 3-4 posts)

bubelov commented 2 years ago

@p-fruck and it happens only on Android 12? Is it reproducible? Are there articles which always fail? If so, can you provide an example feed and an article so I can try to reproduce it

p-fruck commented 2 years ago

@bubelov Seems to be an android 12 issue to me, same configuration on android 10 seems to work. To reproduce, simply open the detail-view of an artical a few times in a row and the app will crash. The issue is not specific to a specific article, but happens on each article if I open it multiple times (usually not more than 5x).

Edit: The android 10 device installed nextcloud from google play, I installed nextcloud from F-Droid. Not sure if this makes a difference, both devices use nc SSO

bubelov commented 2 years ago

@p-fruck can you try it with direct login? If you have security concerns, you can create a throwaway account just for this test and then delete it. It would show us for sure if the issue is related to SSO of NC integration in general

p-fruck commented 2 years ago

@bubelov I can reproduce the issue with direct login. Very strange.

bubelov commented 2 years ago

@p-fruck so you still having crashes with direct login? What's your Nextcloud Server and Nextcloud News app versions?

bubelov commented 2 years ago

@p-fruck one more thing, can you try to login with Miniflux and check some news/feeds and see if the app crashes? It will tell us if the issue is with NC integration or every server-based backend

URL: https://news.bubelov.com User: test Password: newstest

Feel free to change anything in this account

p-fruck commented 2 years ago

@bubelov Yes I have. I am running Nextcloud v22.2.3 dockerized and have news v16.2.1 installed. When looking at the results of docker-compose logs -f I got the following output for a successful and a failed request:

# This request succeeded
app_1  | <MY_IP> - user 24/Nov/2021:16:09:41 +0000 "PUT /index.php" 200
web_1  | <MY_IP> - user [24/Nov/2021:16:09:41 +0000] "PUT /index.php/apps/news/api/v1-2/items/read/multiple? HTTP/1.1" 200 4 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.17.1" "<MY_IP>"

# This request failed
app_1  | <MY_IP> - user 24/Nov/2021:16:09:46 +0000 "PUT /index.php" 200
web_1  | <MY_IP> - user [24/Nov/2021:16:09:46 +0000] "PUT /index.php/apps/news/api/v1-2/items/read/multiple? HTTP/1.1" 200 4 "-" "Mozilla/5.0 (Android) Nextcloud-android/3.17.1" "<MY_IP>"

Both requests seem to succeed with status code 200, but the second request failed...

I've just tried your miniflux (thanks for this support!) where I made two attempts to view an article. The first attempt succeeded, the second didn't. Still the same issue

bubelov commented 2 years ago

Just tested on Android 12 with my NC instance and direct login, no crashes. NC Nextcloud 22.1.1, News Server 16.2.1

OK, so it looks like it happens with all remote servers, that suggests connectivity issue and improper handling on the app side. I will try to add a global exception handler in order to catch the stack trace of this issue and show it inside app

@p-fruck also, if you're a dev or familiar with dev tools, you can launch the app from git code in Android Studio and see the error in the "logcat" tab. It should work pretty much out of the box

bubelov commented 2 years ago

@p-fruck my theory is that it fails on a network call, probably on sending the "read" flag

p-fruck commented 2 years ago

@bubelov I've setup logcat and captured the following error message:

[11-24 17:37:52.978 13956:20418 D/OwnCloudClient #0]
REQUEST PUT /index.php/apps/news/api/v1-2/items/read/multiple

[11-24 17:37:53.008 27582:27582 E/AndroidRuntime]
FATAL EXCEPTION: main
Process: co.appreactor.news, PID: 27582
java.lang.IllegalArgumentException: At least one dimension has to be positive number.
    at com.squareup.picasso.Request$Builder.resize(Request.java:324)
    at com.squareup.picasso.RequestCreator.resize(RequestCreator.java:235)
    at entry.TextViewImageGetter$getDrawable$1$1.invokeSuspend(TextViewImageGetter.kt:22)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7840)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ExecInit.main(ExecInit.java:48)
    at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
    at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:355)

[11-24 17:37:53.013 1548:6682 W/ActivityTaskManager]
  Force finishing activity co.appreactor.news/common.AppActivity

The UI somehow seems to report a width < 0 which isn't supported. Do you have any idea how this could happen?

bubelov commented 2 years ago

@p-fruck no idea, but it seems like the text view reports zero width under certain conditions. That's unexpected, but I'll add an exception handler as a first line of defense. At least it will stop crashing. After that, I'll have a look on what may be causing that

bubelov commented 2 years ago

@p-fruck I added some exception handling and logging, it should stop crashing in preview build

citizenserious commented 2 years ago

I still have this issue when scrolling, when I disable "Mark scrollend entries as read" the app does work, had this in every build so far. v0.3.4 NC v23.0.2 (but also in every version before) NC News v17.0.1 Android 11 I would provide a crash log if I knew how to do so.

bubelov commented 2 years ago

@citizenserious crash log sharing is enabled for preview builds so you can try that. If the app detects a crash, it should initiate crash log sharing. I'm planning to enable this feature for all future builds

https://github.com/bubelov/news/releases/tag/preview

citizenserious commented 2 years ago

java.lang.NullPointerException at db.app.EntryQueriesImpl$selectByReadOrBookmarked$1.invoke(DatabaseImpl.kt:767) at db.app.EntryQueriesImpl$selectByReadOrBookmarked$1.invoke(DatabaseImpl.kt:765) at com.squareup.sqldelight.Query.executeAsList(Query.kt:135) at com.squareup.sqldelight.runtime.coroutines.FlowQuery$mapToList$1$1.invokeSuspend(FlowExtensions.kt:98) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

I got the exact same log when logging in directly.

bubelov commented 2 years ago

@citizenserious looks like an issue with database schema or date validation

  1. Can you try to make a clean install? Just delete the app manually and install the latest F-Droid version from scratch
  2. If it keeps crashing, try to clean install the latest preview version. I made a few changes to the code, so it should give us more details if it crashes on date validation
citizenserious commented 2 years ago

@bubelov I did

  1. a clean install with the latest F-Droid version 0.3.4 it crashes like before.
  2. install the latest preview version from 2h ago and it was also crashing. Seems to be the same log as before, but maybe I missed something, so:

java.lang.NullPointerException at db.app.EntryQueriesImpl$selectByReadOrBookmarked$1.invoke(DatabaseImpl.kt:767) at db.app.EntryQueriesImpl$selectByReadOrBookmarked$1.invoke(DatabaseImpl.kt:765) at com.squareup.sqldelight.Query.executeAsList(Query.kt:135) at com.squareup.sqldelight.runtime.coroutines.FlowQuery$mapToList$1$1.invokeSuspend(FlowExtensions.kt:98) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)

bubelov commented 2 years ago

@citizenserious something isn't right with the database. Are you using Nextcloud?

If so, can you try any other backend? You can use my Miniflux server to check if it crashes (feel free to add/remove any feeds):

URL: https://news.bubelov.com User: test Password: newstest

bubelov commented 2 years ago

@citizenserious you mentioned direct login so I assume you're using Nextcloud. It's really hard to rely on this backend because it can return null for pretty much any field and the database doesn't like it at all. I think it just failing too late, it allowed corrupted/incomplete data from the server and now it can't read it. If should probably fail earlier (at sync time) or just ignore invalid news entries. I'm just trying to figure out its related to NC or your hardware (most likely NC)

citizenserious commented 2 years ago

@bubelov I tested it with your Miniflux server, there is no crash. Yes I use Nextcloud v23.0.2 and Nextcloud News v17.0.1 (had the issue also in every version before so far) I also tried the official app for nextcloud news, works for me with the mark as read while scrolling option. But I would like to use your app tough (;

bubelov commented 2 years ago

@citizenserious will you be able to provide the full state so I can reproduce your issue? The app keeps it's state in a single file which contains an SQLite database. It's will contain all of your data though, but the only really sensitive thing is a column called nextcloudServerPassword in Conf table, which can be deleted with the following query:

UPDATE Conf SET nextcloudServerPassword = '';

The export function is in the Settings --> Export Database

citizenserious commented 2 years ago

@bubelov I exported the database file but I do not know how do execute the query. Tried to find the line in a editor but I could not find it.

bubelov commented 2 years ago

@citizenserious which editor did you use? Conf table should have exaxtly one row, your password is in this row, you can just replace it with empty string or any random word.

citizenserious commented 2 years ago

@bubelov I just used the windows editor. I found a line with "nextcloudServerPassword" and it looks empty, maybe because I am logged in over the nextcloud app? I do not know what you mean with Conf table. If you tell me that this is okay, I will post the file here.

bubelov commented 2 years ago

@citizenserious I see. It needs a special editor, you can try this one:

https://sqlitebrowser.org/

citizenserious commented 2 years ago

Thanks for the help, I never had to use database files before.

bubelov commented 2 years ago

@citizenserious thanks for providing test data, I was able to plug it but the phone didn't crash during scrolling. Can you please verify that the app still crashes if you enable airplane mode (no Internet)?

citizenserious commented 2 years ago

Yes it also crashes when in airplane mode. The database is containing my real data, its not test data, I hope I removed every sensitive information correctly like you told me to :D

bubelov commented 2 years ago

@citizenserious depends on your definition of sensitive =) Apart from settings, it's only articles and feeds, which are public anyway

I'm getting out of ideas on what might cause this issue. The really strange thing is that you don't have crashes if you turn "mark scrolled as read" off. The code from your stack trace isn't related to this preference, it gets called only from "show preview" function. Can you please try to disable showing preview images in settings?

citizenserious commented 2 years ago

@bubelov you are right, with disabled "show preview" it no longer crashes.

bubelov commented 2 years ago

@citizenserious I see. You can use this "fix" for now, I'll try to fix this issue in the next release. Thank you for your cooperation =)

citizenserious commented 2 years ago

Thank you very much for your time and effort and for providing this app (: people like you keep the internet running for every one like it really should. Keep up the good work.

doronbehar commented 2 years ago

I also get:

Screenshot_20220927-095645_Readrops