-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught error over multiple paste (or other action) over an image #1578
Comments
I can confirm this issue. |
ps.: Does not happen on docs page https://ckeditor.com/docs/ckeditor5/latest/examples/builds/balloon-editor.html |
Can you paste here simplified HTML which causes this issue? The page you used may be changed soon and we may not be able to reproduce this issue yet.
Does it mean it's a regression? |
Sooooo the minimal set of content Here is a very long snippet with 200
|
Simplified case:
|
OK so the problem was the fake selection container (FSC) in the DOM. The The FSC is not a part of a view that diff should care about. It has own logic for rendering in the renderer. Previously (i might be wrong here) the diff method marked FSC from the DOM as removed element or it was removing it and other rendering algorithms didn't bother with it. The fastDiff created different results when the FSC was in the DOM hence the renderer tried to rended unexisting node (or do something with it). I have a fix for but I only need to add tests to it. The solution is to remove the FSC before running any diff methods. |
I'm testing with this content: let d = '<figure class="image"><img alt="bar" src="sample.jpg"></figure>';
for ( let i = 0; i < 200; ++i ) {
d += `<p>${ i }</p>`;
}
editor.setData( d ); The TC is:
What I see in If this method was responsible for rendering the FSC, then it'd be a valid result. HOWEVER, FSC is being rendered by other methods. It's not one of the "children" to be rendered. And so, it should not be used when diffing or mapping children. At least that's how it was meant to be when we were implementing it because I'm not sure what happens now. |
This is baaaaad. FSC's being re-rendered by the renderer like there's no tomorrow. It seems that every time root children are being modified, the FSC is first being removed by the These are results of quoting and unquoting the image several times: The image is selected for the entire period and there should be no need to touch FSC. And yet we constantly add and remove it. Now, interestingly, I cannot easily show that removing FSC for a brief moment will cause any issues. However, I will insist on being careful with it. I can imagine browsers doing weird things if you suddenly remove the element in which the selection was placed. It will vary based on what's around that element and whether this is a mobile/desktop browser (e.g. iOS has more tendency to scroll to the selection). It also doesn't mean anything that it works this way today because those things are still not speced. Furthermore, there are screen readers which are going to read the selection changes. Finally, there's ckeditor/ckeditor5-engine#1610 which I now understand. It was completely unclear to me because Therefore, we should find a way to skip FSC when comparing nodes. Fortunately, it seems that there are only two places where we use "actual DOM children" and we can (hopefully) ignore this element there. Curious if this is going to work... |
I created a quick PoC in ckeditor/ckeditor5-engine#1687. It seems to fix both issues (both errors that were logged) and all tests pass. |
I was testing the solution from ckeditor/ckeditor5-engine#1687 and I was able to reproduce the same error as in the first post. It occurs also on Steps to reproduce
Error
GIF |
Normal
first fast diff
Second fast diff (different output again)
Third fast diff (error)
On the above the last relevant elements are presented and matched to the diff output. All previous normal diff gives the same output on the last (relevant) places: |
Let's extract this to a separate ticket. Doesn't seem to be a critical issue and should not block the release. @Mgsy, could you report a new ticket for it for iteration23? |
Fix: Filter out fake selection container before comparing DOM view root children in view renderer. Closes ckeditor/ckeditor5#1578.
Is this a bug report or feature request? (choose one)
🐞 Bug report
💻 Version of CKEditor
latest master (with this PR but probably unrelated)
📋 Steps to reproduce
✅ Expected result
Should work.
❎ Actual result
Error is thrown:
Most of the times:
Sometimes:
📃 Other details that might be useful
It's easier to spot this error with larger content. Ie pasting an image with 3-4 paragraphs might not be enough to cause it.
Spotted on Chrome.
The text was updated successfully, but these errors were encountered: