Description
Description
On django-cms projects with a large number of sub-sites, editing/adding/removing/changing position on plugins freezes the browser for around a minute. On some devices the page crashes or becomes unresponsive indefinitely. We identified this to be caused by diff-dom library struggling with large amounts of html elements when trying to refresh the page's toolbar content. After a plugin is added or modified or removed, the page fetches new html data, then using diff-dom it creates a diff and applies it to the old toolbar html elements. However, the diff creation process takes unusually long when the toolbar contents contain a large amount of html elements. In our case, we have a django-cms project with 382 sites in it, and this process takes about 50 seconds. Increasing the number of sites increases the time exponentially.
We have a fix for this and will create a pull request shortly. If it's up to django-cms' standards, you can accept it, otherwise, feel free to suggest changes or add any of your own.
Steps to reproduce
- Create a django-cms project with 400 sub-sites.
- Create a page in any of the sites and add any plugin to it. We commonly tested this using the text plugin.
- Confirm that after the plugin is added, the page stays greyed-out and unresponsive for around a minute. On some devices, the browser may crash.
Expected behaviour
Refreshing the content after plugin addition should not take more than a few seconds.
Actual behaviour
Adding a plugin on pages of projects with large amount of sites freezes the page for around a minute on some devices, or crashes the browser on others.
Additional information (CMS/Python/Django versions)
django-cms version 3.7.4
django version 2.2.17