ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

Throttle UI update event

Open mlewand opened this issue 2 years ago • 3 comments

📝 Provide a description of the improvement

The update event is sometimes called very frequently, examples include:

  • image resize it fires on each image resize redraw,
  • dragging content over the editable (I believe it's due to caret showing the potential drop placement),
  • simply holding right arrow key (to keep moving selection),
  • column resize

It's similar to what we had in browsers couple of years ago with the scroll event, which in the end got throttled too.


If you'd like to see this improvement implemented, add a 👍 reaction to this post.

mlewand avatar May 09 '23 07:05 mlewand

I wonder whether the source event should be throttled or the consumer should throttle their listeners?

IDK the full story behind the scroll event, but I'd expect:

  • people blindly plugging into it with heavy code
  • the event itself being deep in the browser engine's internal, possibly in another thread that takes care of rendering, hence generating a ton of complexity when trying to sync with another thread and a blocking JS event handlers

The former is a case for us too perhaps, but the latter (I guess?) has a lower impact on us.

With throttling the original event, I have a problem that there may be code that actually needs an unthrottled one.

Maybe we should have:

  • EditorUI#update throttled
  • EditorUI#updateUnsafeSynchronous not throttled

BTW, am I right that moving listeners of #update to a throttled event will ensure that if a UI-related logic throws, it does not interfere with the rest of the code (error goes into the global scope)?

Reinmar avatar May 10 '23 06:05 Reinmar

Pardon my ignorance, what's the impact, and what problems are caused by the update being not throttled? Could there be some other solution to it?

Witoso avatar May 10 '23 06:05 Witoso

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

CKEditorBot avatar May 10 '24 03:05 CKEditorBot

We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

CKEditorBot avatar Jun 09 '24 03:06 CKEditorBot