Content items with a large number of field collection items (20+) are slow to load. It seems that when there is a WYSIWYG field in a field collection, any AJAX call reloads the ckeditor.
Case:
- Node contains around 70 field collections and each has around 3 text editor.
- On edit content, ckeditor/xss gets call for each text editor which contains the text, that is 70 field collection X 3 Ckeditor = 210 xss calls.
- Now when we click on Add another in edit content, 210 ckeditor/xss get call again (for existing text editors).
- It seems Ckeditor gets detach and attach (reload) again when we do AJAX operations.
This is affecting performance for editing such heavy nodes and some times gets hanged.
Now i want to know which solution could be the best one:
Solution 1:
For editing nodes, ckeditor/xss should be checked at the time of submit and not during loading of ckeditor
Solution 2:
Any AJAX call should not trigger unloading and loading of Ckeditor which in returns call ckeditor/xss
If there is any other solution, please let me know.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | drulenium_ckeditor.gif | 20.57 KB | technikh |
| #8 | ckeditor-batch-xss-2578271.patch | 4.88 KB | lotyrin |
| #8 | ckeditor-async-xss-2578271.patch | 488 bytes | lotyrin |
| #8 | 0005-Use-a-timeout-to-batch-multiple-calls-to-XSS-service.patch | 2.07 KB | lotyrin |
| #8 | 0004-Allow-batches-of-text-to-be-filtered-by-XSS-service.patch | 2.88 KB | lotyrin |
Comments
Comment #2
fabianderijkI've ran into this issue as well. I've created a patch that will create a option in the general settings form to make the ajax call asynchronously instead of the now fixed synchronous call.
Changing the call to asynchronous basically means that the rendering of the page won't wait anymore on the Ajax calls. Especially on pages with large amounts of WYSIWYG fields this means a large performance gain.
Comment #3
Koen.Pasman commented+1 on the patch in #2
Works like a charm.
Comment #4
lotyrin commentedThis patch is nice, but why make this configurable? When would you want these requests to be synchronous, blocking ANY user interaction until all the wysiwyg fields finish loading?
They should also probably be batched: one round-trip, one Drupal bootstrap time.
Furthermore, why does this processing even happen server-side but after the page is loaded?
Should it not happen during the initial request, if not, should it not happen client side?
Comment #5
lotyrin commentedHere's a much simpler async patch.
Comment #7
lotyrin commentedBTW, I'm not just being contrary about the async point. Chrome before this patch gives me a nice console log message:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
The docs from WHATWG elaborate as follows:
Synchronous XMLHttpRequest outside of workers is in the process of being removed from the web platform as it has detrimental effects to the end user's experience. (This is a long process that takes many years.) Developers must not pass false for the async argument when entry settings object's global object is a Window object. User agents are strongly encouraged to warn about such usage in developer tools and may experiment with throwing an InvalidAccessError exception when it occurs.
Too bad more browsers aren't moving forward with the InvalidAccessError exception, otherwise this code wouldn't have ended up in this module in the first place.
Comment #8
lotyrin commentedUpdated patches.
The sequentially numbered are straight from git format-patch, they're my branch I've been working on this in.
I've got two Drupal-formatted patches, one for just making this async, the other goes further to allow batch processing.
Comment #9
lotyrin commentedOn my problematic form, I go from 110 requests to 38 requests with batch coalescing.
Comment #10
lotyrin commentedComment #23
technikh commented@lotyrin, Your patch ckeditor-async-xss-2578271.patch resulted in blank white page for admin/config/content/ckeditor/addg page, as reported by Drulenium visual regression test. Complete report at http://drulenium.org/projects/drupal-module-ckeditor-7x-1x-desktop/conso...

Console Log: https://gitlab.com/Drulenium-bot/ckeditor/builds/3927283#down-build-trace
Comment #24
altcom_neil commented@loytrin
Thanks for your work, this has been driving me mad for ages. I have even been creating multiple admin pages just to mitigate the long load time of CK Editor.
I applied the ckeditor-batch-xss-2578271.patch and my page load for an admin page with lots of text format fields has gone from making 22 separate xss requests taking almost 30 seconds to load the page to 1 xss request and the page loading in under 6 seconds! The 1 request getting all the info takes the same amount of time as an individual request did before.
I will do some further testing but I have not found anything no longer working.
Comment #25
socialnicheguru commentedis this an issue in Drupal8?
Comment #26
rcodinaI experience the same problem using paragraphs. My workaround is in ckeditor.utils.js:166 and I replaced this...
...with this...
Drupal.ckeditorInit(textarea_id);Comment #27
philsward commentedStruggling with this... Any updates coming?
Comment #28
philsward commentedv1.19
Patch: ckeditor-batch-xss-2578271.patch
On a side note, I updated to 1.19 and tried to apply this patch before actually testing things... I re-downloaded a clean 1.19 and tested without the patch. The editor loads pretty quickly so I guess we'll see what happens.
Comment #29
miguelbraga commentedFor the time being, under D7, this solves my issue:
// Prevent unwanted caching.
if (false && run_filter && ($("#" + textarea_id).val().length > 0) && typeof(ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]]) != 'undefined' && ((ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]]['ss'] == 1 && typeof(Drupal.settings.ckeditor.autostart) != 'undefined' && typeof(Drupal.settings.ckeditor.autostart[textarea_id]) != 'undefined') || ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]]['ss'] == 2)) {
// if (run_filter && ($("#" + textarea_id).val().length > 0) && typeof(ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]]) != 'undefined' && ((ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]]['ss'] == 1 && typeof(Drupal.settings.ckeditor.autostart) != 'undefined' && typeof(Drupal.settings.ckeditor.autostart[textarea_id]) != 'undefined') || ckeditor_obj.input_formats[ckeditor_obj.elements[textarea_id]]['ss'] == 2)) {
$.ajax({
type: 'POST',
url: Drupal.settings.ckeditor.xss_url,
Comment #30
bburgThis patch will be a huge relief to some particularly complex sites with a lot of fields. Though currently the batch processing patch doesn't apply cleanly to the current 2.21 release. Also, if I just apply the async patch, I begin getting an error message like this, for what I assume is each CKEditor instance.
Though this doesn't seem to affect my ability to interact with the form. I'm still apprehensive to commit a a patch that generates an error like this.