stefan-niedermann / nextcloud-deck

📋 Android client for nextcloud deck app
https://play.google.com/store/apps/details?id=it.niedermann.nextcloud.deck.play
GNU General Public License v3.0
501 stars 53 forks source link

App crash while importing data - Window allocation of 2048 kb failed. #1210

Closed TtuxX closed 2 years ago

TtuxX commented 2 years ago

Hi there @stefan-niedermann and @desperateCoder ! :)

I hope you are doing fine and I wish you a Happy New Year !! :)

I am publishing this issue again (mentioned in my comment on issue https://github.com/stefan-niedermann/nextcloud-deck/issues/1117) as Deck app has not worked for me since the end of septembre 2021 and I miss it a lot for my day-to-day organisation!

Describe the bug

The Deck app crashes when trying to connect the app for the first time after clearing app data.

The app throws an error related to something like "too many open files", then the error window pops-up (hiding the message), with one of the two error messages listed in this bug report's stacktrace section.

Steps to reproduce the behavior:

  1. Login inside the Deck app
  2. Boards import starts
  3. App crashes at board 5/25, throwing a "Cursor window allocation of 2048 kb failed."
  4. See error stacktrace, at the end of this bug report

Expected behavior

All the data is imported and the app works as expected.

Versions

Smartphone (please complete the following information):

Stacktrace


Full Crash:

App Version: 1.20.0
App Version Code: 1020000
App Flavor: fdroid
Files App Version Code: 30020499

---

OS Version: 4.4.23+(157(C432))
OS API Level: 26
Device: HWBLA
Manufacturer: HUAWEI
Model (and Product): BLA-L29 (BLA-L29)

---

android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 
    at android.database.CursorWindow.<init>(CursorWindow.java:110)
    at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
    at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138)
    at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
    at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219)
    at android.database.AbstractCursor.moveToNext(AbstractCursor.java:268)
    at androidx.room.InvalidationTracker$1.checkUpdatedTable(InvalidationTracker.java:461)
    at androidx.room.InvalidationTracker$1.run(InvalidationTracker.java:431)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:784)

Full Crash:

App Version: 1.20.0
App Version Code: 1020000
App Flavor: fdroid

Files App Version Code: 30020499

---

OS Version: 4.4.23+(157(C432))
OS API Level: 26
Device: HWBLA
Manufacturer: HUAWEI
Model (and Product): BLA-L29 (BLA-L29)

---

java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
    at android.view.InputChannel.nativeReadFromParcel(Native Method)
    at android.view.InputChannel.readFromParcel(InputChannel.java:148)
    at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:804)
    at android.view.ViewRootImpl.setView(ViewRootImpl.java:845)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:372)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:128)
    at android.app.Dialog.show(Dialog.java:454)
    at androidx.fragment.app.DialogFragment.onStart(DialogFragment.java:687)
    at androidx.fragment.app.Fragment.performStart(Fragment.java:3021)
    at androidx.fragment.app.FragmentStateManager.start(FragmentStateManager.java:589)
    at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:300)
    at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2189)
    at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:2100)
    at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:2002)
    at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:524)
    at android.os.Handler.handleCallback(Handler.java:808)
    at android.os.Handler.dispatchMessage(Handler.java:101)
    at android.os.Looper.loop(Looper.java:166)
    at android.app.ActivityThread.main(ActivityThread.java:7425)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

Thank you very much in advance to you both for your kind help ! :)

stefan-niedermann commented 2 years ago

@desperateCoder looks like the issue we already knew about regarding too much activity on the database?

Maybe we should try to limit certain synchronization steps to batches? The change shouldn't be too big because we already are running te stuff on CachedThreadpoolExecutors which could be changed to executors with a fixed thread pool size?

stefan-niedermann commented 2 years ago

@TtuxX this is just a trial and error, but I'd like to ask you to test this debug build (download, unzip and install it - it can be used alongside the Deck Android app from F-Droid). It will be slower then you might be used to because I chose a quite low limit (10) of parallel actions just to see whether this fixes the issue at all. Please note that this build requires the Nextcloud Android app to be at least version 3.18.x, so make sure that you have a recent version - your Dev build of Nextcloud Android seems to be a bit outdated.

desperateCoder commented 2 years ago

We can make a build with strict mode enabled (detectLeakedClosableObjects and (detectLeakedSqLiteObjects), I'll try that as soon as I find time for that and post the APK here. Since I can't reproduce that behavior, i depend on your help here @TtuxX

TtuxX commented 2 years ago

Thank you very much to you both for your kind help and for being so responsive!

@stefan-niedermann I confirm your debug build - while indeed slower - works, and import of large deck entries works fine! When I closed the app and started it again, tables where imported and ready to use.

At some point however during my tests with your new debug app I got an error message that I cannot reliably reproduce for now:

App Version: 1.20.0
App Version Code: 1020000
Server App Version: 1.6.0
App Flavor: dev
Files App Version Code: 30020499

---

OS Version: 4.4.23+(157(C432))
OS API Level: 26
Device: HWBLA
Manufacturer: HUAWEI
Model (and Product): BLA-L29 (BLA-L29)

---

android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (Sqlite code 787), (OS error - 11:Try again)
    at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
    at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:818
    at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:803)
    at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
    at androidx.sqlite.db.framework.FrameworkSQLiteStatement.executeInsert(FrameworkSQLiteStatement.java:51)
    at androidx.room.EntityInsertionAdapter.insertAndReturnId(EntityInsertionAdapter.java:114)
    at it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.UserDao_Impl.insert(UserDao_Impl.java:177)
    at it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.UserDao_Impl.insert(UserDao_Impl.java:29)
    at it.niedermann.nextcloud.deck.persistence.sync.adapters.db.DataBaseAdapter.createUser(DataBaseAdapter.java:358)
    at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider.fixRelations(CardDataProvider.java:96)
    at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider.createInDB(CardDataProvider.java:79)
    at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider.createInDB(CardDataProvider.java:32)
    at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper$1.onResponse(SyncHelper.java:62)
    at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper$1.onResponse(SyncHelper.java:47)
    at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:59)
    at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:54)
    at it.niedermann.nextcloud.deck.api.RequestHelper$ResponseConsumer.accept(RequestHelper.java:56)
    at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
    at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58)
    at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:62
    at io.reactivex.internal.operators.observable.ObservableFromPublisher$PublisherSubscriber.onNext(ObservableFromPublisher.java:56)
    at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$1$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:130)
    at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda2.subscribe(Unknown Source:6)
    at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31)
    at io.reactivex.Observable.subscribe(Observable.java:12284)
    at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
    at io.reactivex.Observable.subscribe(Observable.java:12284)
    at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
    at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
    at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
    at java.lang.Thread.run(Thread.java:784)

Note: I updated my Nextcloud Dev app to the very last version as you suggested and I now remember why I was keeping this old version: Notes app does not work anymore as it does not see my account I added again on the Nextcloud Dev app, and throws an Attempt to invoke virtual method 'java.lang.String android.virtual.content.Intent.getStringExtra(java.lang.String)' on a null object reference.

@desperateCoder No worries, thank you for your precious help, I remain of course at your entire disposal to help you try test versions and debug this issue!

stefan-niedermann commented 2 years ago

@TtuxX thanks for the feedback! Yeah, let's focus on one issue after another - as I mentioned, this was a hard limit to check whether it solves the issue at all. Before we can push the changes to production, we need to try a few more real world scenarios.

It would be great if you could clear the storage of the Deck Android Dev app, uninstall it and then test this build - does the import still work? How is the performance compared to the version of September you mentioned and how is the performance compared to the first debug build?

TtuxX commented 2 years ago

Thank you @stefan-niedermann ! The app loads faster than the previous one but crashes at the exact same point than the current Master version of Deck app available on F-Droid. It throws again the same "Cursor window allocation of 2048 kb failed.", with a subliminal message "Too many open files" just before the crash pop-up.

desperateCoder commented 2 years ago

@TtuxX could you please test this APK and gather logcat-logs? If your device is rooted maybe via MatLog or if not via ADB (adb logcat > log.txt)? It should now log possible violations, so we can find the leak.

What I'm interested in is the logs from right before you start the app until it crashes. There might be some private data in it, since the logging outputs the contents of your cards, but I just need the parts stating something about a "violation".

So if you have recorded the logs, just search for the word "violation" and copy the found blocks here (there might be multiple blocks).

That would help a lot! Thanks in advance! And of course, if you need help gathering the logs, just ask!

TtuxX commented 2 years ago

@desperateCoder Thank you for your help ! I have my log file ready but have not found any occurrence of "violation" keyword. Where could I privately upload my log file for you to access it ? Do you have an e-mail address or something else I could join you at ?

Edit: Maybe this log would be relevant? ``` 0119 19:01:55.070 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.071 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.073 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.073 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.076 6432 8556 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.076 6432 8558 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.076 6432 8553 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.076 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.076 6432 8560 D com.nextcloud.android.sso.api.AidlNetworkRequest: copy data from service finished 01-19 19:01:55.076 6432 8561 D com.nextcloud.android.sso.api.AidlNetworkRequest: copy data from service finished 01-19 19:01:55.077 6432 8562 D com.nextcloud.android.sso.api.AidlNetworkRequest: copy data from service finished 01-19 19:01:55.077 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.078 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.078 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.079 6432 7295 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.079 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.080 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.080 6432 6444 I zygote64: Background concurrent copying GC freed 126426(11MB) AllocSpace objects, 83(3MB) LOS objects, 49% free, 14MB/29MB, paused 764us total 127.856ms 01-19 19:01:55.080 6432 7295 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.081 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.081 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.081 6432 7295 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.081 6432 7295 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.081 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.082 6432 7295 W zygote64: ashmem_create_region failed for 'indirect ref table': Too many open files 01-19 19:01:55.083 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.083 6432 7295 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.084 6432 7295 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.084 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.084 6432 7295 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.084 6432 7295 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.084 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.085 6432 7295 W zygote64: ashmem_create_region failed for 'indirect ref table': Too many open files 01-19 19:01:55.085 6432 7307 W zygote64: ashmem_create_region failed for 'indirect ref table': Too many open files 01-19 19:01:55.086 6432 7241 E CursorWindow: ashmem_create_region ashmemFd=-1, result=-24 01-19 19:01:55.086 6432 7350 E CursorWindow: ashmem_create_region ashmemFd=-1, result=-24 01-19 19:01:55.086 6432 7241 E CursorWindow: Could not allocate CursorWindow '/data/user/0/it.niedermann.nextcloud.deck.dev/databases/NC_DECK_DB.db' of size 2097152 due to error -24. 01-19 19:01:55.086 6432 7350 E CursorWindow: Could not allocate CursorWindow '/data/user/0/it.niedermann.nextcloud.deck.dev/databases/NC_DECK_DB.db' of size 2097152 due to error -24. 01-19 19:01:55.086 6432 7295 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.086 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.086 6432 8568 W zygote64: ashmem_create_region failed for 'indirect ref table': Too many open files 01-19 19:01:55.086 6432 7295 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.087 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.087 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.087 6432 7295 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.087 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.088 6432 7307 W zygote64: ashmem_create_region failed for 'indirect ref table': Too many open files 01-19 19:01:55.088 6432 7295 W zygote64: ashmem_create_region failed for 'indirect ref table': Too many open files 01-19 19:01:55.088 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.089 6432 7307 E IPCThreadState: More than IPC_START_MONITOR_LEVEL, start Monitor 01-19 19:01:55.089 6432 7350 E DeckLog : (IResponseCallback.java:13) $default$onError() ‚Üí android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 01-19 19:01:55.089 6432 7350 E DeckLog : at android.database.CursorWindow.(CursorWindow.java:110) 01-19 19:01:55.089 6432 7350 E DeckLog : at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) 01-19 19:01:55.089 6432 7350 E DeckLog : at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138) 01-19 19:01:55.089 6432 7350 E DeckLog : at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) 01-19 19:01:55.089 6432 7350 E DeckLog : at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219) 01-19 19:01:55.089 6432 7350 E DeckLog : at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.CardDao_Impl.getCardByRemoteIdDirectly(CardDao_Impl.java:2926) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.adapters.db.DataBaseAdapter.getCardByRemoteIdDirectly(DataBaseAdapter.java:224) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardLabelRelationshipProvider.deleteAllExisting(CardLabelRelationshipProvider.java:40) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper.fixRelations(SyncHelper.java:180) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:137) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:32) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper$1.onResponse(SyncHelper.java:77) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper$1.onResponse(SyncHelper.java:47) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:59) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:54) 01-19 19:01:55.089 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.api.RequestHelper$ResponseConsumer.accept(RequestHelper.java:56) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:62) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableFromPublisher$PublisherSubscriber.onNext(ObservableFromPublisher.java:56) 01-19 19:01:55.089 6432 7350 E DeckLog : at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$1$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:130) 01-19 19:01:55.089 6432 7350 E DeckLog : at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda2.subscribe(Unknown Source:6) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.Observable.subscribe(Observable.java:12284) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.Observable.subscribe(Observable.java:12284) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38) 01-19 19:01:55.089 6432 7350 E DeckLog : at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26) 01-19 19:01:55.089 6432 7350 E DeckLog : at java.util.concurrent.FutureTask.run(FutureTask.java:266) 01-19 19:01:55.089 6432 7350 E DeckLog : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 01-19 19:01:55.089 6432 7350 E DeckLog : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 01-19 19:01:55.089 6432 7350 E DeckLog : at java.lang.Thread.run(Thread.java:784) 01-19 19:01:55.090 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: WARNING: Header not set - key or value missing! Key: If-Modified-Since | Value: null 01-19 19:01:55.090 6432 7307 D com.nextcloud.android.sso.api.NextcloudRetrofitServiceMethod: invoke call to api using observable class it.niedermann.nextcloud.deck.model.full.FullCard 01-19 19:01:55.090 6432 7350 E DeckLog : (IResponseCallback.java:13) $default$onError() ‚Üí android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. 01-19 19:01:55.090 6432 7350 E DeckLog : at android.database.CursorWindow.(CursorWindow.java:110) 01-19 19:01:55.090 6432 7350 E DeckLog : at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198) 01-19 19:01:55.090 6432 7350 E DeckLog : at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:138) 01-19 19:01:55.090 6432 7350 E DeckLog : at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132) 01-19 19:01:55.090 6432 7350 E DeckLog : at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:219) 01-19 19:01:55.090 6432 7350 E DeckLog : at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:258) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.adapters.db.dao.CardDao_Impl.getCardByRemoteIdDirectly(CardDao_Impl.java:2926) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.adapters.db.DataBaseAdapter.getCardByRemoteIdDirectly(DataBaseAdapter.java:224) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardLabelRelationshipProvider.deleteAllExisting(CardLabelRelationshipProvider.java:40) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper.fixRelations(SyncHelper.java:180) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:137) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider.goDeeper(CardDataProvider.java:32) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper$1.onResponse(SyncHelper.java:77) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.SyncHelper$1.onResponse(SyncHelper.java:47) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:59) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.persistence.sync.helpers.providers.CardDataProvider$1.onResponse(CardDataProvider.java:54) 01-19 19:01:55.090 6432 7350 E DeckLog : at it.niedermann.nextcloud.deck.api.RequestHelper$ResponseConsumer.accept(RequestHelper.java:56) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:62) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableFromPublisher$PublisherSubscriber.onNext(ObservableFromPublisher.java:56) 01-19 19:01:55.090 6432 7350 E DeckLog : at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$1$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:130) 01-19 19:01:55.090 6432 7350 E DeckLog : at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda2.subscribe(Unknown Source:6) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.Observable.subscribe(Observable.java:12284) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.Observable.subscribe(Observable.java:12284) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38) 01-19 19:01:55.090 6432 7350 E DeckLog : at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26) 01-19 19:01:55.090 6432 7350 E DeckLog : at java.util.concurrent.FutureTask.run(FutureTask.java:266) 01-19 19:01:55.090 6432 7350 E DeckLog : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 01-19 19:01:55.090 6432 7350 E DeckLog : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 01-19 19:01:55.090 6432 7350 E DeckLog : at java.lang.Thread.run(Thread.java:784) 01-19 19:01:55.090 6432 8565 E DeckLog : (IResponseCallback.java:13) $default$onError() ‚Üí java.lang.RuntimeException: Too many open files 01-19 19:01:55.090 6432 8565 E DeckLog : at android.os.Parcel.nativeWriteFileDescriptor(Native Method) 01-19 19:01:55.090 6432 8565 E DeckLog : at android.os.Parcel.writeFileDescriptor(Parcel.java:669) 01-19 19:01:55.090 6432 8565 E DeckLog : at android.os.ParcelFileDescriptor.writeToParcel(ParcelFileDescriptor.java:1026) 01-19 19:01:55.090 6432 8565 E DeckLog : at com.nextcloud.android.sso.aidl.IInputStreamService$Stub$Proxy.performNextcloudRequestV2(IInputStreamService.java:307) 01-19 19:01:55.090 6432 8565 E DeckLog : at com.nextcloud.android.sso.api.AidlNetworkRequest.performAidlNetworkRequestV2(AidlNetworkRequest.java:313) 01-19 19:01:55.090 6432 8565 E DeckLog : at com.nextcloud.android.sso.api.AidlNetworkRequest.performNetworkRequestV2(AidlNetworkRequest.java:180) 01-19 19:01:55.090 6432 8565 E DeckLog : at com.nextcloud.android.sso.api.NextcloudAPI.performNetworkRequestV2(NextcloudAPI.java:199) 01-19 19:01:55.090 6432 8565 E DeckLog : at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$1$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:129) 01-19 19:01:55.090 6432 8565 E DeckLog : at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda2.subscribe(Unknown Source:6) 01-19 19:01:55.090 6432 8565 E DeckLog : at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31) 01-19 19:01:55.090 6432 8565 E DeckLog : at io.reactivex.Observable.subscribe(Observable.java:12284) 01-19 19:01:55.090 6432 8565 E DeckLog : at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32) 01-19 19:01:55.090 6432 8565 E DeckLog : at io.reactivex.Observable.subscribe(Observable.java:12284) 01-19 19:01:55.090 6432 8565 E DeckLog : at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96) 01-19 19:01:55.090 6432 8565 E DeckLog : at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38) 01-19 19:01:55.090 6432 8565 E DeckLog : at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26) 01-19 19:01:55.090 6432 8565 E DeckLog : at java.util.concurrent.FutureTask.run(FutureTask.java:266) 01-19 19:01:55.090 6432 8565 E DeckLog : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 01-19 19:01:55.090 6432 8565 E DeckLog : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 01-19 19:01:55.090 6432 8565 E DeckLog : at java.lang.Thread.run(Thread.java:784)- ```
desperateCoder commented 2 years ago

@TtuxX the posted log is already quite interesting, but if you don't mind I'd like see the full one, too. You can mail it to @stefan-niedermann (into@niedermann.it).

I already found a couple of suspicious things while investigating this issue, I just can't proof it for now. Thanks for leading us to this! I hope I can dive deeper into this and get a clearer view of where the leaks exactly happen, but I'm already quite convinced that there are leaks. Not in our code though (we never make mistakes :stuck_out_tongue_winking_eye: ), but in a library we use.

Any logs from you would be helpful. Just to make sure: you installed the APK in my previous post, cleared data of the dev app, started gathering logs, started the app, imported until it died and then took the logs? I'm asking because even I get the violation output in the logs, without the app even crashing. If you did all that steps, it's fine too.

And one more question: do you have a few images attached to your cards?

TtuxX commented 2 years ago

Logcat file sent to Stefan!

Haha with pleasure! I hope you find the root cause :)

In your described sequence I missed the step of clearing the storage, my bad! :( I installed your Dev app that was previously uninstalled, started gathering the logs, connected the account inside the Android Deck app, then it died importing data. I waited few seconds more, then took the logs. If you want I will send you logs again tomorrow, ensuring I properly clear data before starting the app.

However from my previous tests on past days I confirm that this error systematically occurs, whether I delete data or not before connecting the account inside the app.

Image attacments: I don't have any "cover" images attached to my cards, but I do have heavy decks with many cards (I use the app a lot) and do have few files attached too (not many).

desperateCoder commented 2 years ago

@TtuxX thanks for both logs! I'll dive into this, hopefully I can find some time this weekend.

Image attacments: I don't have any "cover" images attached to my cards, but I do have heavy decks with many cards (I use the app a lot) and do have few files attached too (not many).

Thats fine, so I can check that later on, doesn't seem to be this particular problem then.

desperateCoder commented 2 years ago

@TtuxX sorry for the lack of communication lately.

Here is a footage of me during the last two weeks:

https://youtu.be/AbSehcT19u0

What I'm trying to say is that it still might take a while... I'll update you here as soon as there are some news

TtuxX commented 2 years ago

@desperateCoder Haha thank you very much for the update, I appreciate it! :)

I feel for you haha Digging into unexpected code issues often result into this kind of situation.

No worries, thank you so much again for your time and kind help! For now I can use the slow debug version that kinda works (except some unexpected crashes while opening some cards).

I hope you will be able to trace the origin of this bug without too much time and difficulty :)

stefan-niedermann commented 2 years ago

Will be fixed in 1.20.1 - please reopen in case the error still happens with this or a higher version. Thanks everyone for testing and helping analysing this issue!

TtuxX commented 1 year ago

Hi there! :)

I hope the team is doing fine!

I am again having an SSO login issue and cannot login on version 1.23.4.

Sync never properly ends unfortunately

App Version: 1.23.4
App Version Code: 1023004
Server App Version: 1.11.0
App Flavor: fdroid

Files App Version Code: 30260090 (PROD)
Files App Version Code: 20231014 (DEV)

---

OS Version: 4.19.278-gbf451ea24640(2023101300)
OS API Level: 34
Device: redfin
Manufacturer: Google
Model (and Product): Pixel 5 (redfin)

---

android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787 SQLITE_CONSTRAINT_FOREIGNKEY)
    at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
    at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:961)
    at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:790)
    at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:89)
    at androidx.sqlite.db.framework.FrameworkSQLiteStatement.executeInsert(FrameworkSQLiteStatement.kt:42)
    at androidx.room.EntityInsertionAdapter.insertAndReturnId(EntityInsertionAdapter.kt:102)
    at it.niedermann.nextcloud.deck.database.dao.CommentDao_Impl.insert(CommentDao_Impl.java:221)
    at it.niedermann.nextcloud.deck.database.dao.CommentDao_Impl.insert(CommentDao_Impl.java:31)
    at it.niedermann.nextcloud.deck.database.DataBaseAdapter.createComment(DataBaseAdapter.java:1152)
    at it.niedermann.nextcloud.deck.remote.helpers.providers.DeckCommentsDataProvider.createInDB(DeckCommentsDataProvider.java:81)
    at it.niedermann.nextcloud.deck.remote.helpers.providers.DeckCommentsDataProvider.createInDB(DeckCommentsDataProvider.java:21)
    at it.niedermann.nextcloud.deck.remote.helpers.SyncHelper$1.onResponse(SyncHelper.java:62)
    at it.niedermann.nextcloud.deck.remote.helpers.SyncHelper$1.onResponse(SyncHelper.java:47)
    at it.niedermann.nextcloud.deck.remote.helpers.providers.DeckCommentsDataProvider$1.onResponse(DeckCommentsDataProvider.java:41)
    at it.niedermann.nextcloud.deck.remote.helpers.providers.DeckCommentsDataProvider$1.onResponse(DeckCommentsDataProvider.java:32)
    at it.niedermann.nextcloud.deck.remote.api.RequestHelper$ResponseConsumer.accept(RequestHelper.java:52)
    at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:63)
    at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58)
    at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:62)
    at io.reactivex.internal.operators.observable.ObservableFromPublisher$PublisherSubscriber.onNext(ObservableFromPublisher.java:56)
    at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$0$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:123)
    at com.nextcloud.android.sso.api.NextcloudAPI$$ExternalSyntheticLambda0.subscribe(Unknown Source:6)
    at io.reactivex.internal.operators.observable.ObservableFromPublisher.subscribeActual(ObservableFromPublisher.java:31)
    at io.reactivex.Observable.subscribe(Observable.java:12284)
    at io.reactivex.internal.operators.observable.ObservableMap.subscribeActual(ObservableMap.java:32)
    at io.reactivex.Observable.subscribe(Observable.java:12284)
    at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96)
    at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:38)
    at io.reactivex.internal.schedulers.ScheduledDirectTask.call(ScheduledDirectTask.java:26)
    at java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
    at java.lang.Thread.run(Thread.java:1012)
stefan-niedermann commented 1 year ago

@TtuxX your recent issue is unrelated to both, this issue and the SSO login mechanism. It's a duplicate of https://github.com/stefan-niedermann/nextcloud-deck/issues/1447 please follow the discussion there 👋 It's a race condition. As a workaround try clearing the storage of Deck Android as described in the FAQ ans try to login - repeat this multiple times until it works (ör we find the actual root cause)

TtuxX commented 1 year ago

Wooops, sorry for this and thanks for the link !! I tried many times force-stopping, erasing data and importing again but it never worked. Either crashed during the process or stalled at 37/39 boards without ever finishing.

zjacreman commented 7 months ago

Seeing the "Cursor window allocation of 2048 kb failed" error in 1.24.1 from fdroid. Rolling back to 1.23.4 fixed it.

Huawei MediaPad M5 lite 10 running Android/EMUI 8. Didn't see the same issue on my phone, running Android 13.