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

Markdown editor: Note rerenders even when the markdown preview pane is hidden #9891

Closed
personalizedrefrigerator opened this issue Feb 8, 2024 · 0 comments · Fixed by #9901
Labels
bug It's a bug desktop All desktop platforms

Comments

@personalizedrefrigerator
Copy link
Collaborator

personalizedrefrigerator commented Feb 8, 2024

Operating system

Linux

Joplin version

2.14.12

Desktop version info

No response

Current behaviour

  1. Apply the following diff (log when rerenders happen)
diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx
index 5136f4141..3656551cf 100644
--- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx
+++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx
@@ -624,6 +624,7 @@ function CodeMirror(props: NoteBodyEditorProps, ref: ForwardedRef<NoteBodyEditor
 				noteId: props.noteId,
 				vendorDir: bridge().vendorDir(),
 			}));
+			console.log('rerender (v5)')
 
 			if (cancelled) return;
 
diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx
index e678c0657..ba2a85345 100644
--- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx
+++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx
@@ -233,6 +233,7 @@ const CodeMirror = (props: NoteBodyEditorProps, ref: ForwardedRef<NoteBodyEditor
 				noteId: props.noteId,
 				vendorDir: bridge().vendorDir(),
 			}));
+			console.log('Rerender');
 
 			if (cancelled) return;
 
  1. Hide the markdown preview
  2. Clear the console
  3. Edit a note

Currently, even when the markdown preview is hidden, notes rerender. For long notes (e.g. the one created to test this issue), this can freeze the UI for 1-2 seconds while rendering happens, interrupting typing.

This happens both with the legacy and beta markdown editors.

Expected behaviour

Joplin should not rerender notes when the note preview pane is not visible.

Logs

CodeMirror 6 editor:

Console was cleared
undefined
main-html.js:54 08:44:39: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 08:44:39: Scheduling sync operation... 15000
main-html.js:54 Rerender
main-html.js:54 08:44:40: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 08:44:41: Scheduling sync operation... 15000
main-html.js:54 08:44:42: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 08:44:42: Scheduling sync operation... 15000
main-html.js:54 Rerender
lib.js:205 [Violation] 'message' handler took 4914ms
[Violation] Forced reflow while executing JavaScript took 4745ms
main-html.js:54 Got ipc-message: noteRenderComplete undefined
main-html.js:54 08:44:49: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 08:44:49: SearchEngine: Updating FTS table...
main-html.js:54 08:44:49: Scheduling sync operation... 15000
main-html.js:54 Rerender
lib.js:205 [Violation] 'message' handler took 5063ms
[Violation] Forced reflow while executing JavaScript took 4909ms
main-html.js:54 Got ipc-message: noteRenderComplete undefined

CodeMirror 5 editor:

Console was cleared
undefined
main-html.js:54 08:46:24: models/Setting: Settings have been saved.
main-html.js:54 08:46:28: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 08:46:29: Scheduling sync operation... 15000
main-html.js:54 08:46:29: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 08:46:29: Scheduling sync operation... 15000
main-html.js:54 rerender (v5)
lib.js:205 [Violation] 'message' handler took 4927ms
[Violation] Forced reflow while executing JavaScript took 4783ms
main-html.js:54 08:46:36: ResourceService::indexNoteResources: Start
main-html.js:54 08:46:36: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 Got ipc-message: noteRenderComplete undefined
main-html.js:54 rerender (v5)
main-html.js:54 08:46:37: Scheduling sync operation... 15000
main-html.js:54 08:46:37: models/Setting: Saving settings...
main-html.js:54 08:46:37: models/Setting: Settings have been saved.
main-html.js:54 08:46:37: ResourceService::indexNoteResources: Completed
main-html.js:54 08:46:37: ResourceService::deleteOrphanResources:
main-html.js:54 08:46:38: Saving note... {id: '76b44d666f8240f0a13900f25d919eb9', parent_id: '03f60d453a054b01b163c27174451fa8', title: 'Long', body: 'The Project Gutenberg eBook of Frankenstein; Or, T…our email newsletter to hear about new eBooks.\n\n\n'}
main-html.js:54 08:46:38: Scheduling sync operation... 15000
main-html.js:54 08:46:39: SearchEngine: Updating FTS table...
main-html.js:54 rerender (v5)
lib.js:205 [Violation] 'message' handler took 5174ms
[Violation] Forced reflow while executing JavaScript took 5003ms
main-html.js:54 Got ipc-message: noteRenderComplete undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug desktop All desktop platforms
Projects
None yet
1 participant