Mobile: Image editor beta: Image edits not syncing

Summary

Modification/update times aren't being updated by the beta image editor on iOS and Android.
This causes changes to drawings not to be synced.

It should be fixed by this (merged) pull request. A new beta release should be available soon. Until one is, be aware that drawings may not sync properly.

Preventing data loss on sync

The next time a resource is edited in a way that does update the modification timestamp, that copy of the resource may overwrite other copies without producing conflicts. This is because its timestamp will be newer than all other versions of that drawing, which all have their timestamp set to their creation date.

To prevent edited copies from being lost, you can

  1. Make a JEX backup (Configuration > Scroll down to "Export" > Export all notes as JEX). This saves the edited — but not correctly synced — drawings to the JEX export file (tested on iOS).
  2. Alternatively, long-press on a drawing and click "share" to save the modified copies of the drawing externally.
  3. After the pull request is merged, opening a drawing in the image editor and clicking Save should update the drawing's last modified timestamp. (Make sure that the version you first click "Save" on is the version you want to keep! Incorrect last modified times may prevent conflicting changes from being moved to "Conflicts".)

Original post

Overview

While testing the js-draw-based beta editor on iOS, I encountered a very strange sync issue that I haven't since been able to reproduce (except for with a single resource).

Interestingly, there seem to now be two files on OneDrive with the resource's UUID, one in the .resources folder and one with a .md extension. Edit: This is expected. See comment below.

It would be helpful to know if this is happening for anyone else (and if there's a consistent way to reproduce this for new attachments).

What I did

I attached a new drawing by clicking the "Draw picture" button under the note actions menu. I drew something, then clicked save, then close (if I remember correctly).

I then synced my (iOS) device to OneDrive. After that finished, I synced a desktop client to OneDrive. The drawing renders to this:

I then tried editing the drawing on the iOS device and re-syncing. Nothing changed.

Other drawings can be added on the iOS device. After syncing, the other new drawings show up, as expected, on the desktop client.

The markdown for the drawing looks like this:

![Drawing](:/73372e9b8dae434ab2b63b145474cf5e)

If I remove the exclamation mark and click on the link, a dialog shows the error

contextMenu.ts:62 Error: Error: ENOENT: no such file or directory,
lstat '/home/myusername/snap/joplin-desktop/40/.config/joplin-desktop/resources/73372e9b8dae434ab2b63b145474cf5e.svg'.
Path: /home/myusername/snap/joplin-desktop/40/.config/joplin-desktop/resources/73372e9b8dae434ab2b63b145474cf5e.svg

Relevant sections of the log

Most recent logs are first, least recent are last.

10-30T11:14:07: Synchronizer: "Sync: finished: Synchronisation finished [1698689627286]"
10-30T11:14:06: Synchronizer: "Sync: fetchingProcessed: Processing fetched item"
10-30T11:14:06: Synchronizer: "Sync: fetchingProcessed: Processing fetched item"
10-30T11:14:06: Synchronizer: "Sync: fetchingTotal: Fetching delta items from sync target"
10-30T11:14:06: Synchronizer: "BasicDelta: Report: {"timestamp":1698689499640,"older":4073,"newer":2,"equal":0}"
10-30T11:13:53: Synchronizer: "TaskQueue.stop: syncDownload: waiting for tasks to complete: 0"
10-30T11:13:53: Synchronizer: "TaskQueue.stop: syncDownload: Done, waited for 0"
10-30T11:13:53: RevisionService: "maintenance: Done in 110ms"
10-30T11:13:53: RevisionService: "collectRevisions: Created revisions for 0 notes"
10-30T11:13:53: Synchronizer: "Sync: updateRemote: local has changes: Resource: (Local 73372e9b8dae434ab2b63b145474cf5e): (Remote 73372e9b8dae434ab2b63b145474cf5e.md)"
[[...removed...]]
10-30T11:02:53: Synchronizer: "Sync: createRemote: remote does not exist, and local is new and has never been synced: Revision: (Local 380825b6c0624faf8f845b604b292059)"
10-30T11:02:53: Synchronizer: "Sync: updateRemote: local has changes: Resource: (Local 73372e9b8dae434ab2b63b145474cf5e): (Remote 73372e9b8dae434ab2b63b145474cf5e.md)"
10-30T11:02:51: Synchronizer: "Sync: updateRemote: local has changes: Note: (Local d29687d7a54149459086afc2460bc62d): (Remote d29687d7a54149459086afc2460bc62d.md)"
10-30T11:02:49: Synchronizer: "Sync target local info:", "{ [[...removed...]] }"
10-30T11:02:49: Synchronizer: "Sync target is already setup - checking it..."
10-30T11:02:48: "ResourceService::indexNoteResources: Completed"
10-30T11:02:48: Synchronizer: "Indexing resources..."
10-30T11:02:48: "ResourceService::indexNoteResources: Start"
10-30T11:02:48: Synchronizer: "Sync: starting: Starting synchronisation to target 3... supportsAccurateTimestamp = false; supportsMultiPut = false [1698688968730]"
10-30T11:02:48: root: "root.biometrics: biometricsDone", "true"
10-30T11:02:48: root: "root.biometrics: biometricsEnabled", "false"
10-30T11:02:48: root: "root.biometrics: shouldShowMainContent", "true"
10-30T11:02:48: root: "root.biometrics: this.state.sensorInfo", "{"enabled":false,"sensorsHaveChanged":false,"supportedSensors":""}"
10-30T11:02:48: "Preparing scheduled sync"
10-30T11:02:48: "Starting scheduled sync"
10-30T11:02:42: RevisionService: "collectRevisions: Created revisions for 1 notes"
10-30T11:02:42: RevisionService: "maintenance: Done in 124ms"
10-30T11:02:42: root: "root.biometrics: biometricsDone", "true"
10-30T11:02:42: root: "root.biometrics: biometricsEnabled", "false"
10-30T11:02:42: root: "root.biometrics: shouldShowMainContent", "true"
10-30T11:02:42: root: "root.biometrics: this.state.sensorInfo", "{"enabled":false,"sensorsHaveChanged":false,"supportedSensors":""}"
10-30T11:02:42: RevisionService: "maintenance: Starting..."
10-30T11:02:42: RevisionService: "maintenance: Service is enabled"
10-30T11:02:41: screens/Note: "Saved drawing to", "/var/mobile/Containers/Data/Application/D9F01A8F-32DE-4519-AF96-2BA507911084/Documents/73372e9b8dae434ab2b63b145474cf5e.svg"
10-30T11:01:49: "SearchEngine: Updated FTS table in 54ms. Inserted: 1. Deleted: 0"
10-30T11:01:49: "SearchEngine: Updating FTS table..."
10-30T11:01:46: root: "root.biometrics: biometricsDone", "true"
10-30T11:01:46: root: "root.biometrics: biometricsEnabled", "false"
10-30T11:01:46: root: "root.biometrics: shouldShowMainContent", "true"
10-30T11:01:46: root: "root.biometrics: this.state.sensorInfo", "{"enabled":false,"sensorsHaveChanged":false,"supportedSensors":""}"
10-30T11:01:46: Synchronizer: "Total folders: 27"
10-30T11:01:46: Synchronizer: "Total notes: 730"
10-30T11:01:46: Synchronizer: "Total resources: 915"
10-30T11:01:46: Synchronizer: "Operations completed: "
10-30T11:01:46: Synchronizer: "createRemote: 1"
10-30T11:01:46: Synchronizer: "updateRemote: 1"
10-30T11:01:46: Synchronizer: "Sync: finished: Synchronisation finished [1698688901280]"
10-30T11:01:46: Synchronizer: "Processing a path that has already been done: 73372e9b8dae434ab2b63b145474cf5e.md. sync_time was not updated? Remote item has an updated_time in the future?"
10-30T11:01:45: Synchronizer: "Sync: updateRemote: local has changes: Note: (Local d29687d7a54149459086afc2460bc62d): (Remote d29687d7a54149459086afc2460bc62d.md)"
10-30T11:01:43: screens/Note: "Saved drawing to", "/var/mobile/Containers/Data/Application/D9F01A8F-32DE-4519-AF96-2BA507911084/Documents/73372e9b8dae434ab2b63b145474cf5e.svg"
10-30T11:01:43: "ResourceService::deleteOrphanResources:", "[]"
10-30T11:01:43: RevisionService: "maintenance: Done in 110ms"
10-30T11:01:43: "ResourceService::indexNoteResources: Completed"
10-30T11:01:43: RevisionService: "collectRevisions: Created revisions for 0 notes"
10-30T11:01:43: Synchronizer: "Sync: createRemote: remote does not exist, and local is new and has never been synced: Resource: (Local 73372e9b8dae434ab2b63b145474cf5e)"
10-30T11:01:43: root: "root.biometrics: biometricsDone", "true"

This line in the logs seems particularly suspicious: 10-30T11:01:46: Synchronizer: "Processing a path that has already been done: 73372e9b8dae434ab2b63b145474cf5e.md. sync_time was not updated? Remote item has an updated_time in the future?"

Files on OneDrive

Interestingly, there are two files with the same UUID on OneDrive:

File 1: 73372e9b8dae434ab2b63b145474cf5e.md:

id: 73372e9b8dae434ab2b63b145474cf5e
mime: 
filename: 
created_time: 
updated_time: 2023-10-30T18:18:53.595Z
user_created_time: 
user_updated_time: 
file_extension: 
encryption_cipher_text: JED0100002205cb62f8af20624c9e8c9fac86632c6032000384{...REMOVED BEFORE POSTING TO DISCOURSE...}
encryption_applied: 1
encryption_blob_encrypted: 
size: 
is_shared: 
share_id: 
master_key_id: 
user_data: 
blob_updated_time: 
type_: 4

The encryption_cipher_text decrypts to

Drawing

id: 73372e9b8dae434ab2b63b145474cf5e
mime: image/svg+xml
filename: 
created_time: 2023-10-30T18:01:43.615Z
updated_time: 2023-10-30T18:18:53.595Z
user_created_time: 2023-10-30T18:01:43.615Z
user_updated_time: 2023-10-30T18:18:53.595Z
file_extension: 
encryption_cipher_text: 
encryption_applied: 0
encryption_blob_encrypted: 1
size: 0
is_shared: 0
share_id: 
master_key_id: 
user_data: 
blob_updated_time: 1698688903615
type_: 4

File 2: .resources/73372e9b8dae434ab2b63b145474cf5e

JED0100002205cb62f8af20624c9e8c9fac86632c6032
1 Like

I'm not sure about the sync_time error, but the explanation for the two files is that one (ID.md) is the metadata and another (.resource/ID.md) is the resource content, so at least this part is normal

1 Like

By quickly adding new drawings to a single note, I've managed to reproduce this for 2-3 more images. These images aren't as empty as the first (they have the base image template), but updates to them don't seem to sync to the desktop client.

I can also reproduce this with Joplin Server.

This should be fixed by

I'm not sure how this was working previously (unless the way resources are saved/synced changed at some point, either in the beta editor or internally).

1 Like

Yes it's because of this change: https://github.com/laurent22/joplin/commit/9aed3e04f43e9e02cd727d6f05a785e4aedad412 which allows updating the resource metadata and content independently. It will be needed for the OCR feature, so that users don't have to re-upload the content of all their resources after we attach the OCR info to the metadata.

So now if we want to modify the content of an existing resource we need to call this "updateResourceContent" method, which updates the right timestamp, and unfortunately I forgot that the image editor on mobile needed to do that.

I'm going to make another beta release of the iOS and Android apps since this can be a major issue for those who use js-draw.

2 Likes

Hi! I think this last version has broken the editor. Plain text editor still working fine.
Two android 13 devices with the same symptom, when I click the edit button the note content disappear. Happy to help if any additional information is required

View:

Content disappear:

Plain editor:

I can confirm this on iOS.

It seems to work with a local development build. I'm now doing a full rebuild to see if that results in a non-working editor.

Bug report:

2 Likes

Which version? And from where? Please consider that "last version" is meaningless for us - it might have changed since you wrote that, and it could be the pre-release or the regular release, it could be the F-Droid version or the Google Play one, etc.

The one that was build to fix the bug on this thread. Thats why I have reported it here, sorry if it was unclear. I will keep it in mind for further comments!

Hi! working fine in Release android-v2.13.6 · laurent22/joplin-android · GitHub
Thanks!

2 Likes