notes-android icon indicating copy to clipboard operation
notes-android copied to clipboard

Sync fails with `DeadObjectException`

Open palegrand opened this issue 2 years ago • 28 comments

Describe the bug opening the app shows 'Synchronisierung fehlgeschlagen' (sync failed). Notes cannot communicate until the phone is rebooted or the Nextcloud-app (NOT the notes-app!) is closed and reopened.

To Reproduce Steps to reproduce the behavior:

  • make sure Nextcloud-app is running in the background
  • open Nextcloud Notes app is working as expected. After some time (regardless if the phone was in use or idle) the error occurs when opening 'notes'

Expected behavior notes app keeps working

Screenshots

Smartphone (please complete the following information):

  • Nextcloud Notes-Version (android app): 3.7.1
  • F-Droid or Play Store: tried both, same problem
  • Android-Version: 13 (LineageOS 20)
  • Device: oneplus 9 pro

Problem occurs on this device only. Other devices with same apps/settings/account in the same network talking to the same server work fine all the time. Network is fine: nextcloud app itselfs keeps working, login with web-browser works fine while 'notes' shows the error Are there particular settings/permissions required for 'notes' itselfs or the nextcloud app on oneplus (or A13)?

Server

  • Nextcloud version: 25.0.3
  • Nextcloud Notes version (server app): 4.6

Stacktrace

App Version: 3.7.1
App Version Code: 3007001
App Flavor: fdroid

Files App Version Code: 30230191

---

OS Version: 5.4.219-qgki-g8683e24ef293(f60dd643e4)
OS API Level: 33
Device: OnePlus9Pro
Manufacturer: OnePlus
Model (and Product): LE2123 (OnePlus9Pro)

---

java.lang.RuntimeException: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe
at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46)
at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:93)
at io.reactivex.Maybe.blockingGet(Maybe.java:2321)
at io.reactivex.Observable.blockingSingle(Observable.java:5381)
at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pullRemoteChanges(NotesServerSyncTask.java:219)
at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run(NotesServerSyncTask.java:96)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:463)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
at java.lang.Thread.run(Thread.java:1012)
Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffe
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(BinderProxy.java:584)
at com.nextcloud.android.sso.aidl.IInputStreamService$Stub$Proxy.performNextcloudRequestV2(IInputStreamService.java:312)
at com.nextcloud.android.sso.api.AidlNetworkRequest.performAidlNetworkRequestV2(AidlNetworkRequest.java:313)
at com.nextcloud.android.sso.api.AidlNetworkRequest.performNetworkRequestV2(AidlNetworkRequest.java:180)
at com.nextcloud.android.sso.api.NextcloudAPI.performNetworkRequestV2(NextcloudAPI.java:199)
at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$1$com-nextcloud-android-sso-api-NextcloudAPI(NextcloudAPI.java:129)
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.ObservableSingleMaybe.subscribeActual(ObservableSingleMaybe.java:31)
at io.reactivex.Maybe.subscribe(Maybe.java:4290)
at io.reactivex.Maybe.blockingGet(Maybe.java:2320)
... 8 more

palegrand avatar Feb 01 '23 08:02 palegrand

Seems that NC Files app was killed by OS. Have you set this to be excluded from battery saving mechanism?

tobiasKaminsky avatar Feb 01 '23 14:02 tobiasKaminsky

yes - but I'll re-check. There are some options (e.g. 'Pause app activity if unused') I'm not familar with using older versions of Android or other brands of phones...

I agree that an interrupted 'relay' would create this kind of trouble. Is the nextcloud-app used as a 'relay'? I'm basically puzzled because notes does work fine if nextcloud-app isn't open - and it does not seem to open it in the background. Is there a kind of a fall-back mechanism if the nextcloud-app is not running?

palegrand avatar Feb 01 '23 16:02 palegrand

'Pause app activity if unused' and allowing NC to run in background all the time does NOT work: still crashes.
Opposed to my first observations notes DOES crash even if NC-app is not running. To have 'notes' working again in this condition I need to start NC first... this seems to 'reset' the connection somehow.

palegrand avatar Feb 01 '23 21:02 palegrand

Notes is using Files app to communicate with server. This way Notes does not have to deal with authentication, http clients, etc.

tobiasKaminsky avatar Feb 02 '23 08:02 tobiasKaminsky

do you mean the default Files ('Dateien') app of LineageOS? I did not think about this one... I'm excluding it from optimization at once!

palegrand avatar Feb 02 '23 09:02 palegrand

No with "Files" he means the main Nextcloud Android app: https://play.google.com/store/apps/details?id=com.nextcloud.client

stefan-niedermann avatar Feb 02 '23 10:02 stefan-niedermann

that's the 'NC-client' app I suspected in the first place (since restarting it cures the problem temporarily) and I excluded it from battery optimization yesterday. Unfortunately the problem persists with these settings. I'm not sure if I over-look something (my other devices are based on Android 10...) : I set Einstellungen - Apps - Nextcloud - 'Akkunutzung von Apps' to 'uneingeschränkt'... is there something else to take care off?

palegrand avatar Feb 02 '23 10:02 palegrand

For normal brands this is enough. I have a OnePlus (but with LineageOS), so I cannot say if this enough.

Our friends from DavX5 have the same problem. Maybe it is worth to check their FAQ: https://www.davx5.com/faq/synchronization-is-not-run-as-expected or this: https://dontkillmyapp.com/oneplus?app=DAVx%E2%81%B5

tobiasKaminsky avatar Feb 02 '23 11:02 tobiasKaminsky

I'm running LOS 20 on a OnePlus as well, so it should be similar ;-) what android-settings did you adjust for NC-app and notes-app? dav5x fails with exactly the same error if run automatically (triggering by hand works fine, background start yields to the same exception as I found out in the meantime...) Thanks for the links - I'll check them out out

palegrand avatar Feb 02 '23 12:02 palegrand

LOS20:

  • long press app
  • app info
  • battery settings --> not restricted (the first one) (roughly translated from German)

It sometimes says that sync fails, but then next sync is working. I also use Nextcloud News app, which is set to refresh every 15 min.

tobiasKaminsky avatar Feb 02 '23 13:02 tobiasKaminsky

Thanks. I'm Swiss, my phone is set to the same language as yours ;-)
that is exactly what I did for both NC-app and Notes-app. Any other app to take care off? I set the refresh rate to 2 hours. Three crashes today with notes - and davx5 afterwards (same exception). kept notes closed and davx5 synced at least two times without hicup in the background. I keep observing...

palegrand avatar Feb 02 '23 16:02 palegrand

To narrow down the problem I restricted communication to wifi only, set the sync interval of davx5 to the shortest possible time and compare 4 situations
1 davx5 2 davx5 + nc 3 davx5 + nc + notes 4 davx5 + nc + notes_with_open_note

calendar is open to verify davx5 is working, otherwise I do not touch the phone while 4 crashed most of the times at the next sync (leading to the same exception in davx5 as in notes!) 1 and 2 never crashed so far. despite the fact it's the same exception it looks like running notes is the 'trigger'... too early to be sure... I will now test 4 to 1 (instead of 1 to 4) to tell apart a memory leak elsewhere that strikes after a number or calls...

palegrand avatar Feb 03 '23 07:02 palegrand

Many thanks for this deep "debugging". Maybe we can then enhance it :crossed_fingers:

tobiasKaminsky avatar Feb 03 '23 08:02 tobiasKaminsky

thanks for your support! it speaks for 'Notes' since I try hard to get it working on this device :-) 1-4 or 4-1 did not make a difference. but by chance is discovered something else...

I have a strong&stable wifi and two SIM-cards. After switching mobile data off things ran perfect. After switching mobile data on and wifi off instead - to my surprise things ran perfect as well! But allowing BOTH seems to make Notes and to some point davx5 prone to the reported exception - even while connected to a stable wifi . I'm sure about wifi since I monitored it with iperf3: uninterrupted, fast and stable with or without mobile data enabled. Posslibly OnePlus makes the mobile data hardware 'sleep' if wifi is available, NC /davx5 try nevertheless to query/access available network interfaces and the oneplus cannot reliabily unfreeze the mobile part fast enough? I could reproduce the problem multiple times. I now allow wifi only to nc/davx5 and monitor it for a longer time. runs stable so far - including notes :-)

palegrand avatar Feb 03 '23 13:02 palegrand

  • wifi only (disabling mobile data) ran fine for a day. davx5 ran perfectly as well
  • mobile data only (disabling wifi) ran mostly fine (two exceptions, vanished after refreshing the screen). davx5 did hard crash (reboot required) twice problem seems linked to the way my oneplus handles mobile data...

palegrand avatar Feb 04 '23 08:02 palegrand

Hm. I also have two sim cards, but only one with mobile data. Do you have with both cards mobile data?

tobiasKaminsky avatar Feb 06 '23 06:02 tobiasKaminsky

just one. but I tried all combinations, even with just one sim (containing phone and mobile data) in either slot - same result. Very few crashes with wifi, quite frequent with mobile data... But I made an interesting observation: out of 100+ apps just 3 generate a problem... same exception, and usually almost at the same time: Notes,davx5 and Firefox. since davx5 crashed by 'contacts' (just sometimes and while running in the background) I set the sync for contacts to 'manual' and kept syncing just calendar automatically. Hard to believe: not a single crash with firefox or davx5 ever since - independent of wifi/mobile data! long/big transactions in davx5 in the background seem to be a problem... I opened a case there. Maybe you use a similar approach - different to the NC-app...? Notes does still shows the same problem. after restarting the NC-app it is working again. Strange thing is: NC-app itselfs runs flawlessly. Using it to manage the text-notes works in any condition, never needed to restart. How is this possible since Notes communicates thru it?

palegrand avatar Feb 06 '23 07:02 palegrand

Can you check for log files on Nextcloud Files side, when this happens? Maybe there is something, and a transaction is too big and thus communication from Notes fails…

Can you also link your report on DavX5 here?

tobiasKaminsky avatar Feb 06 '23 14:02 tobiasKaminsky

Nextcloud side: are you referring to the server side? (nothing special there) if NC-App: where do I find the log there? I doubt I find something there because it never shows an error message and is working all the time. I only restart it to get Notes running again (restarting notes does not help. just restarting nc-app makes notes working again) ;-)

Reported to davx5 by mail, unfortunately i don't have the url. Ticket#15355, whole title is "RE: sync crash oneplus9pro / Android 13 [Ticket#15355]"

I only have some 25 notes, the biggest one is 4k... no big files at all.

I can confirm that doing a sync of contacts 'manually' works fine all the time in davx5 (not a single crash since I set it up that way!) - and I can reproduce the crash by allowing it in the background and waiting a few cycles. seems independent of wifi or mobile data, just syncing in the background is enough in some conditions.Unfortunately I can't tell the 'conditions'... but at least I can reproduce it now. Since it fails with the same exception as Notes there might be a common origin...

palegrand avatar Feb 06 '23 21:02 palegrand

Accessing logs on NC Files will work with RC1/beta releases of it. Other than that, via https://github.com/nextcloud/android/blob/master/README.md#getting-debug-info-via-logcat

But it is a bit more effort and I am unsure if there is really something to find…

tobiasKaminsky avatar Feb 07 '23 06:02 tobiasKaminsky

I'm a few days off now and the phone will be in my pocket, i.e. hard to do usb debugging at the same time... I'll give it a try next weekend. FYI: davx5 runs fine with 15-min-interval - even with contacts - and without any exceptions if 'extensive protocol' (Ausführliche Protokollierung) is enabled?! All other options (even 'im Vordergrund bleiben') do yield to the known exception after some time...

palegrand avatar Feb 07 '23 08:02 palegrand

just got a mail from a maintainer of LOS20: might be same problem as https://gitlab.com/LineageOS/issues/android/-/issues/5384 LOS seems to mess up long-lasting open connections in the background... Does Notes keep a connection open all the time?

palegrand avatar Feb 20 '23 09:02 palegrand

Does Notes keep a connection open all the time?

Yes - according to @David-Development

If you need to make multiple calls, keep it open as long as you can. This way the services will stay active and the connection between the files app and your app is already established when you make subsequent requests. Otherwise you'll have to bind to the service again and again for each request. (Source)

stefan-niedermann avatar Feb 20 '23 10:02 stefan-niedermann

Then this might hit the problem described in LOS issue #5384. OnePlus seems to have changed the value of cached_apps_freezer to false - just yesterday - I'm checking if that resolves this issue as well. Thanks for pointing this out!

palegrand avatar Feb 20 '23 10:02 palegrand

dev.options 'Suspend execution for cached app' = disabled solves the problem: set it 3 days ago, not a single exception ever since :-) Android default seems to be 'enabled', but most manufacturers set it to 'disabled' in their official rom (foer sure true for Samsung and OnePlus). BTW: OnePlus changed the value to 'disabled' last Monday in their open source part ;-)

Technically I agree that a connection should stay open while in use, but for notes that's basically while working on it. When no note is about to be edited or at very latest when the app looses the focus I'd suggest to close the connection because interaction will not happen and a reconnect is not time-critical.

palegrand avatar Feb 23 '23 10:02 palegrand

Also getting:

App Version: 4.0.0 RC1
App Version Code: 40000051
App Flavor: fdroid

Files App Version Code: 30240190

---

OS Version: 3.18.31-perf-gd33f902(1906418273f7d)
OS API Level: 24
Device: sf340n
Manufacturer: LGE
Model (and Product): LG-M470 (sf340n_global_ca)

---

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object com.google.gson.Gson.fromJson(java.io.Reader, java.lang.reflect.Type)' on a null object reference
	at com.nextcloud.android.sso.api.NextcloudAPI.convertStreamToTargetEntity(NextcloudAPI.java:159)
	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$$ExternalSyntheticLambda0.subscribe(D8$$SyntheticClass)
	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.ObservableSingleMaybe.subscribeActual(ObservableSingleMaybe.java:31)
	at io.reactivex.Maybe.subscribe(Maybe.java:4290)
	at io.reactivex.Maybe.blockingGet(Maybe.java:2320)
	at io.reactivex.Observable.blockingSingle(Observable.java:5381)
	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pullRemoteChanges(NotesServerSyncTask.java:219)
	at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run(NotesServerSyncTask.java:96)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
	at java.lang.Thread.run(Thread.java:761)

Both the NC app and the Notes app are exempt from being killed. I had the app working fine before. Decided to delete and reinstall and started getting this error after I moved over to NC26.

I am able to access notes if I use the simple editor. If I switch to "rich editor," a connectivity error will pop up briefly. When I click on a note, I will get the "Error while loading rich editing." But strangely the note will come up using the Rich Text editor. If I switch to the old one, it does without issue.

Worth noting that I am on NC26, latest Notes app 4.7.2 and the latest Notes app the RC 4.0 on Android. Got it from F-Droid.


On Logs I get:

[PHP] Error: session_start(): Ignoring session_start() because a session is already active at /home/xxxxMYDISKxxx/xxxMYSITExxx.com/lib/private/Session/Internal.php#219


Lastly, I will sometimes get the note popping up randomly, as if cut in half on the screen with this error at the very top:

The document has been changed outside of the editor. The changes cannot be applied

daffydock avatar Mar 25 '23 23:03 daffydock

@daffydock your issue is unrelated to the originally reported DeadObjectException. Please create a new issue filling the issue template, thanks.

stefan-niedermann avatar Mar 26 '23 06:03 stefan-niedermann

I'm also affected from android.os.DeadObjectException. The exception message pop ups often when I open the nextcloud notes app:

App Version: 4.2.1 App Version Code: 40020190 App Flavor: fdroid

Files App Version Code: 30290090 (PROD)

 

OS Version: 5.15.104-android13-3-27760517(A546BXXS7BXD1) OS API Level: 34 Device: a54x Manufacturer: samsung Model (and Product): SM-A546B (a54xnaeea)

 

java.lang.RuntimeException: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffer space at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:46) at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:93) at io.reactivex.Maybe.blockingGet(Maybe.java:2321) at io.reactivex.Observable.blockingSingle(Observable.java:5381) at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.pullRemoteChanges(NotesServerSyncTask.java:219) at it.niedermann.owncloud.notes.persistence.NotesServerSyncTask.run(NotesServerSyncTask.java:96) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:487) 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) Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died, but this could also be caused by running out of binder buffer space at android.os.BinderProxy.transactNative(Native Method) at android.os.BinderProxy.transact(BinderProxy.java:662) at com.nextcloud.android.sso.aidl.IInputStreamService$Stub$Proxy.performNextcloudRequestV2(IInputStreamService.java:200) at com.nextcloud.android.sso.api.AidlNetworkRequest.performAidlNetworkRequestV2(AidlNetworkRequest.java:234) at com.nextcloud.android.sso.api.AidlNetworkRequest.performNetworkRequestV2(AidlNetworkRequest.java:181) at com.nextcloud.android.sso.api.NextcloudAPI.performNetworkRequestV2(NextcloudAPI.java:165) at com.nextcloud.android.sso.api.NextcloudAPI.lambda$performRequestObservableV2$0(NextcloudAPI.java:105) at com.nextcloud.android.sso.api.NextcloudAPI.$r8$lambda$2CK7Y9lXWWrtN8jgT_iNTMeTrHU(Unknown Source:0) 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.ObservableSingleMaybe.subscribeActual(ObservableSingleMaybe.java:31) at io.reactivex.Maybe.subscribe(Maybe.java:4290) at io.reactivex.Maybe.blockingGet(Maybe.java:2320) ... 8 more

rizzek1 avatar May 01 '24 19:05 rizzek1