Classic block: Browser hangs when converting large amounts of content to blocks
Describe the bug When converting an especially long document (1,050,212 characters, attached), the browser tab hangs and/or crashes when attempting to convert the single "Classic" block to modern Gutenberg blocks.
To Reproduce Steps to reproduce the behavior:
- Disable the Gutenberg plugin, then create a new post with the following content pasted into the "text" tab within TinyMCE: sample-text-with-markup.txt
- I've also been able to reproduce this without the
<p>tags in the markup: sample-text-without-markup.txt
- Re-enable Gutenberg and attempt to edit the post using the Gutenberg editor
- You should see a single, "Classic" block containing the post content.
- Click the "kebab menu" (three vertically-stacked circles) icon next to the block header to reveal the "More Options" menu, then select "Convert to Blocks"
- Wait 30 seconds or so before your browser either crashes the tab or the UI otherwise becomes frozen.
Expected behavior I would expect that the document would be converted to blocks (as it does with other posts).
If the editor is unable to handle that much content, I'd expect to receive some sort of feedback indicating that the block cannot be converted, ideally with alternate instructions.
Environment:
- OS: macOS 10.12.6
- Browser: Google Chrome version 68.0.3440.84 (Official Build) (64-bit)
- WordPress 4.9.8, Gutenberg 3.4.0.
Refs #8368.
I tried this as well and experienced the same.
My setup:
- OS: Windows 10 64-bit
- Browser: Firefox Quantum 64.0.1 (64-bit) & Chrome Version 68.0.3440.84 (Official Build) (64-bit)
- WordPress 4.9.8, Gutenberg 3.4.0.
Slightly different results on each browser.
Firefox says: A web page is slowing down your browser. What would you like to do? Stop it / Wait
If you stop it, the browser appears to have converted the top paragraph to a block and then just becomes unresponsive. Reloading just makes the Classic block reappear.
Chrome says: Page Unresponsive You can wait for it to become responsive or exit the page Wait / Exit page
Exiting the page gives the Aw, Snap! Reload it - all content back in a Classic block
By the way, that text is 147, 068 words (!)
I spent some time debugging this last week. It deserves another closer look, but from what I was seeing through performance snapshots was a significant amount of time being spent in initializing TinyMCE for each of the paragraph blocks. This may warrant a reconsideration of the idea proposed in #341 (cc @iseulde).
Also discussed today in core-editor Slack: https://wordpress.slack.com/archives/C02QB2JS7/p1534171728000242
Yes, so this is the same issue as #8822? Whether you paste or load the page with the converted same blocks, it's really slow.
Yes, I imagine this is effectively the same as #8822. Let's close this one as there's a decent amount of analysis already in the other issue.