Severe CPU spike when splitting or merging paragraphs in long notes
I am seeing a reproducible performance issue in the Zotero note editor on macOS.
In a long note/paragraph, pressing Enter to split a paragraph can cause Zotero to freeze for several seconds while CPU usage rises to almost 100%. Activity Monitor showed Zotero at about 99.94% CPU during the freeze.
The delay depends strongly on the amount of text after the cursor. If I press Enter near the beginning of a long paragraph, Zotero can freeze for several seconds. If I press Enter near the end of the same paragraph, the operation is almost instantaneous.
I see a similar issue when using Backspace at a paragraph boundary to merge two paragraphs.
Normal text input does not show the same problem. Visual line wrapping is also completely fine. The slowdown seems specifically related to operations that change the paragraph/block structure, such as splitting a paragraph with Enter or merging paragraphs with Backspace.
I initially suspected clipboard contents or images, but further testing suggests that they are unrelated. For example, directly pasting a 1.6 MB image into the note works normally. The slowdown occurs regardless of what is currently in the clipboard.
Steps to reproduce:
Create or open a Zotero note containing a relatively long paragraph.
Place the cursor near the beginning of the paragraph.
Press Enter.
Zotero may become unresponsive for several seconds and CPU usage rises to around 100%.
Repeat the same operation near the end of the paragraph. The delay is much shorter or absent.
A similar slowdown occurs when using Backspace at a paragraph boundary to merge paragraphs.
Expected behavior:
Splitting or merging paragraphs should remain responsive regardless of the amount of text following the cursor.
Actual behavior:
The processing time appears to increase with the amount of text remaining after the cursor, and can cause Zotero to use nearly 100% CPU and temporarily freeze.
This makes me suspect a performance issue in the note editor's paragraph/block split and merge handling, although I do not know the underlying cause.
In a long note/paragraph, pressing Enter to split a paragraph can cause Zotero to freeze for several seconds while CPU usage rises to almost 100%. Activity Monitor showed Zotero at about 99.94% CPU during the freeze.
The delay depends strongly on the amount of text after the cursor. If I press Enter near the beginning of a long paragraph, Zotero can freeze for several seconds. If I press Enter near the end of the same paragraph, the operation is almost instantaneous.
I see a similar issue when using Backspace at a paragraph boundary to merge two paragraphs.
Normal text input does not show the same problem. Visual line wrapping is also completely fine. The slowdown seems specifically related to operations that change the paragraph/block structure, such as splitting a paragraph with Enter or merging paragraphs with Backspace.
I initially suspected clipboard contents or images, but further testing suggests that they are unrelated. For example, directly pasting a 1.6 MB image into the note works normally. The slowdown occurs regardless of what is currently in the clipboard.
Steps to reproduce:
Create or open a Zotero note containing a relatively long paragraph.
Place the cursor near the beginning of the paragraph.
Press Enter.
Zotero may become unresponsive for several seconds and CPU usage rises to around 100%.
Repeat the same operation near the end of the paragraph. The delay is much shorter or absent.
A similar slowdown occurs when using Backspace at a paragraph boundary to merge paragraphs.
Expected behavior:
Splitting or merging paragraphs should remain responsive regardless of the amount of text following the cursor.
Actual behavior:
The processing time appears to increase with the amount of text remaining after the cursor, and can cause Zotero to use nearly 100% CPU and temporarily freeze.
This makes me suspect a performance issue in the note editor's paragraph/block split and merge handling, although I do not know the underlying cause.
Upgrade Storage
The issue seems to be specific to long Chinese text. I can reproduce the severe slowdown consistently when splitting or merging a long paragraph containing Chinese characters.
With similarly long English text, Enter and Backspace are much more responsive and I do not see the same level of freezing.
So the current reproduction condition appears to be:
- Long Chinese paragraph
- Press Enter somewhere well before the end of the paragraph, or use Backspace to merge paragraph blocks
- Zotero CPU rises to nearly 100% and the editor freezes for several seconds
- The more Chinese text remaining after the cursor, the longer the delay appears to be
- The same operation near the end of the paragraph is much faster
- Long English paragraphs appear to be largely unaffected
I also generated a Debug ID while reproducing the issue:
D746834378
This makes me wonder whether the performance issue may be related specifically to handling or reprocessing CJK text when paragraph/block boundaries are changed.