Skip to content
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

Sync fails on Android mobile with error [object Object] #11571

Open
bob7vogel opened this issue Jan 2, 2025 · 8 comments
Open

Sync fails on Android mobile with error [object Object] #11571

bob7vogel opened this issue Jan 2, 2025 · 8 comments
Labels
bug It's a bug

Comments

@bob7vogel
Copy link

Operating system

Android

Joplin version

Joplin Mobile 3.2.3 (prod, android)

Desktop version info

No response

Current behaviour

  1. open Joplin mobile app
  2. perform any action that requires sync (open app, write a note, request manual sync)
  3. sync begins and then errors with (Last error [object Object]
  4. I am certain that new notes from my desktop version are NOT being moved to the phone version due to this error.
  5. This has been previously reported but ignored in 11376 (at least it closed by no action)

Expected behaviour

app syncs without error. the files on the mobile device match the files on the server (Joplin cloud, which i use) and match the files on the desktop
For me this is a critical fault. It means i can't use Joplin as i need to, syncing across all platforms i use.
The issue has been reported (and not fixed) on several other forums (it's hard for the uninitiated user to figure out where support comes from and where these issues need to be raised). All we get back is "can't duplicate issue". Well it seems to be duplicable on every Android device, at least Pixels.
Please, please ask me for any other information you need to resolve this issue.
It seems from error log to be running into entries that are "Row too big to fit into CursorWindow", yet i don't see how to find what entry that is so i might fix that.
I'm running Android version 15. Graphene OS version 15, version code 35.
Phone is a Pixel Pro 7.

Logs

mobile-log.log

@bob7vogel bob7vogel added the bug It's a bug label Jan 2, 2025
@mrjo118
Copy link
Contributor

mrjo118 commented Jan 3, 2025

Looks like at upstream issue:
andpor/react-native-sqlite-storage#364

I can see from the log that the error is happening when selecting the note history. It seems that the error was triggered by the presence of a large note, then making a change to a large amount of the content in a short space of time. Possibly you can rid of the error for you if you delete all the note history, but probably the only way you can successfully do that in your case is to export all your notes as jex, delete the profile on all devices and joplin server, then reimport the backup and resync to joplin server and your devices. If you have a lot of notes then that's probably not what you want to hear, and I can't guarantee that will fix the issue, as it may not require a revision to be created to cause the problem

@bob7vogel
Copy link
Author

bob7vogel commented Jan 3, 2025 via email

@mrjo118
Copy link
Contributor

mrjo118 commented Jan 3, 2025

Will the save to JEX file essentially remove all note history and just give me a set of "clean" notes?
Yes

is there any automated way that i can combine them without creating many duplicates
Unfortunately there isn't. But as you have unsynced changes on multiple devices, definately make sure to make a jex backup on all devices, before attempting to delete your joplin data

I'm not making any changes to a note. I'm just trying to do a straight sync
The revision service (which creates note history items) automatically runs in the background. So it is a previous change you made to a note at some point which has created a revision that has become unreadable whenever you attempt to sync

@mrjo118
Copy link
Contributor

mrjo118 commented Jan 3, 2025

I have an alternative proposal which may be able to fix your sync on Android. I can see from the error log that the sync is failing on a particular part which compares to items which exist on remote, and one of the matching remote revision items causes the error (Synchronizer.ts call to BaseItem.loadItemsByIds).

The sync is working correctly on desktop right? There is a way that you can delete all note history older than 1 day, if you have a Joplin client where the sync is currently working. To do this, do the following:
-Make sure you are using a recent version of Joplin desktop
-Go to Tools > Options > Note History, change the value of 'Keep note history for' to 1, then click Apply
-Go to Help > Synchronisation status, take a screenshot of this screen for reference
-Come back the next day, no earlier than 24 hours later. Start Joplin desktop and do a sync. You should see in the sync status that it is deleting lots of remote items (unless you already had Joplin desktop open when the note history expired, and an auto sync has already deleted the note history)
-Once the sync has completed successfully, click the sync button 1 more time and let it complete
-Go to Help > Synchronisation status. You should see that the number of revisions has dropped significantly since the first time
-Try sync again on Android. Hopefully it will then work
-Revert the 'Keep note history for' value on Joplin desktop to the previous value, if you so wish

If it still does not work, then please come back and post an updated log file for Android and I'll take a look.

EDIT: "Try sync again on Android. Hopefully it will then work" - for other users reading this, it doesn't look like this step works. However, if you instead uninstall Joplin on the problem Android device, then reinstall it and resync your notes, this will solve the issue, providing that the issue is with note history only. Unfortunately this does mean resyncing all your notes from scratch on the problem device, but at least it doesn't require replacing the sync target and full resync on ALL devices

@bob7vogel
Copy link
Author

bob7vogel commented Jan 3, 2025 via email

@bob7vogel
Copy link
Author

bob7vogel commented Jan 6, 2025 via email

@mrjo118
Copy link
Contributor

mrjo118 commented Jan 6, 2025

@bob7vogel You didn't read the instructions wrong, you just read an outdated comment. If possible it helps to reply on GitHub directly so you will see any edits (as I see you replied via email).

I'm glad you could resolve the issue, and thank you for confirming your steps. It sounds like it's not currently possible to delete note history on Android via the revision service or downloading deletions from the sync target when you have been hitting the "Row too big to fit into CursorWindow" error. So the only way to fix currently is deleting Joplin data on the Android device and resyncing notes from scratch.

Ideally if a delete all note history feature would be added to Joplin which avoids selecting the data into memory before deleting, it would allow deleting note history without requiring starting a new profile on Android.

@mrjo118
Copy link
Contributor

mrjo118 commented Jan 6, 2025

I have had a read through all the issue reports relating to the CursorWindow errors and done some code analysis.

Here are the facts: The "Row too big to fit into CursorWindow" error will occur when the size of a single record returned in a select query is greater than the cursor window size which is defined for Android devices specifically. The default size set by Android is around 2mb for most platforms. There is a workaround implemented in the Joplin code to override this value and set it to 50mb.

I have created a note in Joplin desktop which is approx 4.8mb in size and exported it as a jex file (big.jex). Using Android emulator on Android 15, I am unable to reproduce the error by importing big.jex. However, if I remove the workaround implemented in MainApplication.kt and build the code locally, I am able to reproduce the error by simply importing big.jex (no sync setup is required).

This proves that the workaround implemented in MainApplication.kt does work, which is why the Joplin team have not been able to reproduce the error. Looking at the user feedback, in one example it was reported (in a version of Joplin which had this workaround implemented) that the error occurred selecting from revisions, despite not having any individual note which is 50mb or greater in size that could create a revision so large.

I think the most likely cause of the error is due to the logic to override the window size to 50mb not working on some devices. It does not appear to be related to the version of Android, or how powerful the phone is, as it has been reported on old and new phones including high end ones. Therefore I am guessing producing the issue is dependent on the bundled version of sqlite which comes with the Android device. This is supposed to be dependent on the version of Android, however the link here android.database.sqlite | Android Developers says "Some device manufacturers include different versions of SQLite on their devices".
My guess is that if the manufacturer bundles a non standard version of sqlite, it may not use the CursorWindow class, therefore rendering the workaround in Joplin useless.

In the issue reports regarding the error, users have experienced this issue when selecting from 1 of 3 tables: notes, resources and revisions. Therefore, in the event that the user had a device where the workaround does not work correctly, for each of these tables, it would be possible to produce the error in the following scenarios:
-Notes: Having any note which is greater than 2mb would cause the error
-Resources: The resource is not stored in the database, however the OCR text is. Therefore if using OCT, then if the OCR text is greater than 2mb, this would cause the error
-Revisions: If at any point you have a note which is greater than 2mb in size, if the large content is pasted all in one go, or if the revision service 'merges' multiple revisions where it grew gradually, a revision over over 2mb could be created and would cause the error. Once this revision exists on the Android device, it can only be deleted by uninstall, reinstall and re-sync of the profile on the device.

Therefore, if you are someone who has an affected device, you will have to bear in mind these limitations if using an Android device as a client, as this issue probably can't be fixed. For all other users who are not affected by this issue, the 50mb limit instead will apply for each of the above scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug
Projects
None yet
Development

No branches or pull requests

2 participants