Chrome jank on 2020 Mac in a 50k character document

Hi there,

I am seeing Prosemirror slow down at around 50k characters in Chrome on a Macbook 2020 2Ghz Quad-Core Intel Core i5.

This is similar to another thread, and may be a duplicate, but that thread refers to much larger sized documents than 50k characters.

What’s interesting is on my 2021 Apple M1 I don’t see much slow down at all until 250k characters. But maybe this is Apple’s new chip showing its strength.

I’ll share my debug notes if they’re useful to anyone.

I used the editor on the prosemirror.net homepage for testing. I copy and paste the boilerplate content until it is about 40k characters. I used the Chrome Dev Tools Performance pane to inspect what’s going on with browser interaction handling.

I see a significant delay in the start of the keypress event and when the Prosemirror JS callback is invoked that handles the key.

On the Intel Mac, for some reason the browser sees a keydown event, but there is a perceivable delay (50-100ms) before the JavaScript keypress handling code is invoked. The actual Prosemirror callstack only takes 7ms to execute, but seems delayed before firing. See annotated Performance pane screenshot.

Compare this with the same on the M1 mac screenshot.

I notice that the actual keydown event lasts 150ms on the Intel Mac, and 8ms on the M1 Mac.

I’ll probably design around this issue, and make sure to keep my active document smaller than 40k characters.

From the timings you mention this, like in the other thread, seems to be a browser limitation—editable DOM gets slow at a certain point, especially in Chrome. This is very annoying, but I still don’t think it is a good idea to add the level of complication that would be involved in virtual viewporting to this library, and I don’t really see any other way it could address this.