Closed fredck closed 12 months ago
@fredck, could you test whether this issue occurs when WidgetTypeAround is disabled (you'd need to remove it from the Widget plugin deps)
@fredck, could you test whether this issue occurs when WidgetTypeAround is disabled (you'd need to remove it from the Widget plugin deps)
I've just tried it with a local build of GitHub Writer as it suffers with this issue (ckeditor/github-writer#203). Removing that plugin didn't change anything and the glitch is still there. I confirmed that the plugin is disabled because there was no fancy arrows and horizontal carets anymore around the image.
I wasn't able to test it with the base64 example, as described in this issue, but I believe you guys should be able to easily do so. Thanks!
Seems to be related to #7633.
FYI: #7633 is a different issue and there's a PR addressing it.
Thanks for debugging this, @oleq
What worries me, though, is that two similar issues appeared shortly one after another. It's either Chrome's issue or we changed something and it'd be good to know what was that.
Also, besides image upload I can see that normal image paste (image copied from the editor) is affected too. The resize handles are repositioned with a long delay, even 300ms-500ms. This definitely didn't happen before. And as Fred checked, this is not related to WidgetTypeAround. You can even observe the glitch on this gif:
It'd be good to know WTH is happening there. Bisecting it might actually help a lot.
@fredck Can you post some GIFs? I'm having trouble reproducing your issue. It's either too subtle or there are some external factors involved. Thanks!
I also can't reproduce the issue anymore. I saw it previously.
There's a 200ms throttle on redrawing the handles after you click on the image - https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-widget/src/widgetresize.js#L90
I had a pretty straightforward fix for this https://github.com/ckeditor/ckeditor5/pull/7654/commits/6c2a01cf6d52b3691cf781ac358140a12ca540a5 but after Olek's changes I decided to remove it (also because it was related to the config.image.disableResizeHandles
which we decided to get rid of the scope of the ticket).
There should be no delay when the user focuses the image. Throttling makes sense when something happens very frequently. I remember that we added it for performance reasons but that was related to the performance during resizing. Changing how it behaves on image focus must've been coincidental.
Anyway, I'm for changing this – on focus the redraw should be immediate.
@oleq pointed out that we can also think about reconfiguring throttle to execute on the leading edge. That'd shorten the initial reaction.
So, we have two possible solutions:
Can you post some GIFs? I'm having trouble reproducing your issue. It's either too subtle or there are some external factors involved. Thanks!
Was finally able to do so... Chrome:
Firefox:
This was tested with GitHub Writer after upgrading it to CKEditor 5 v21.0.0.
This glitch is also happening on the linked images - when the user is removing a link from the image.
Unfortunately, I couldn’t reproduce exactly the same glitch on Chrome / Firefox. But I tried to follow the whole process step by step with devtools and debugger and I presume that the issue may be related to the reading
status of the file upload. During this stage, an image placeholder is created, but its styling depends on those styles:
This means that the placeholder will expand to the whole width of the editor, no matter how wide / big the uploading image is. When we upload a smaller (and "lighter") image — like 200px or so — the placeholder flashes for a moment (with that blue outline and height equals 0 — BUT the placeholder contains .ck-upload-placeholder-loader
which is this empty upload placeholder svg file — https://github.com/ckeditor/ckeditor5/blob/master/packages/ckeditor5-image/theme/icons/image_placeholder.svg) and disappears.
Then the uploaded image appears instead.
Both, placeholder and actual image have different widths and heights and both have outlines, so it looks like the image stretches and shrinks within a few milliseconds.
EDIT:
Splitting the gifs above, we can see that it's not a progress bar, but the outline itself (don't know why the placeholder has no height here):
Firefox:
Chrome (I don't understand what happened here):
cc @oleq
Thanks, @panr.
I searched git blame and I found out this width: 100%
was introduced along with this PR ckeditor/ckeditor5-theme-lark#188 and addressed this issue #5150. Unfortunately, this does not help much.
I also briefly checked the code and it looks like the part responsible for the "glitch" in FF is somewhere in here https://github.com/ckeditor/ckeditor5/blob/bcf3af6bee1edbd3a6d0c6874e0ad0518f73f518/packages/ckeditor5-image/src/imageupload/imageuploadprogress.js#L85-L104
I started commenting out some of the helpers _hidePlaceholder()
, _showProgressBar()
, _displayLocalImage()
and without them, it looks smooth. So I suppose The Glitch could be caused by many things happening at once because the image is very small and Firefox is quick to read it and upload it (but not as quick as Chrome).
Finally, I decided to capture The Glitch myself. First, I recorded the GIF below in the easy-image manual test on Firefox in 50fps and slowed down to 25%:
And here's the same scenario in the Github Writer Firefox addon (also in slow-mo):
Note there's a difference between vanilla CKEditor 5 and GHWriter. In the former, the image never stretches to 100% at any point. In the latter, there's a clear moment when the outline takes 100% width of the editing root (it has height, though, unlike the screenshot from the @panr comment above). Which brings a couple of questions:
in the vanilla CKEditor 5, the image never stretches horizontally at any point
Hmm... are you sure? I caught this yesterday in imageuploadviaurl.html
manual test 🤔 The image stretches (specifically image placeholder) in the screen below:
https://user-images.githubusercontent.com/1303365/92606924-cc5df980-f2b3-11ea-8e7d-d8789bdcee83.png
And today I made these frames to show how I see the process in my editor (Chrome):
I also briefly checked the code and it looks like the part responsible for the "glitch" in FF is somewhere in here
I bet that the glitch is somewhere in reading
state ;-D
Maybe we should wait a little bit longer and get the image data (width and height) and then show a placeholder that mimics the actual (fixed) image size?
@oleq , please double check the width aspect. @panr is right in saying that it also occurs in vanilla CKE5.
Disclaimer, poor screenshot resolution because… chrome devtools work on such potato screens (make sense from perf perspective).
tl;dr;
4 frames are produced (2 reflows + 2 repaints)
|
|
|
|
Following frames are produced:
|
|
Here are key frames from fredck screencast:
First, the editable gets much bigger, to shrink later on. I assume it's, again, caused by widget wrapper. |
I started commenting out some of the helpers _hidePlaceholder(), _showProgressBar(), _displayLocalImage() and without them
I wonder if that was really the case, as the only thing that I was able to comment out without breaking the feature was _showProgressBar
and with it commented the issue persists. Skipping _displayLocalImage()
keeps us with a placeholder spinner instead of an image, while skipping _hidePlaceholder()
leaves the spinner on top of an image.
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.
We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).
📝 Provide detailed reproduction steps (if any)
✔️ Expected result
Image "uploaded" with no glitches.
❌ Actual result
A perceivable glitch happens.
📃 Other details
I wasn't able to reproduce the problem in Chrome, but it has been reported in GitHub Writer that a similar issue happens in Chrome as well: ckeditor/github-writer#203.
If you'd like to see this fixed sooner, add a 👍 reaction to this post.