Skip to content
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

Improve table column resize performance #13097

Closed
scofalik opened this issue Dec 19, 2022 · 0 comments · Fixed by #13187
Closed

Improve table column resize performance #13097

scofalik opened this issue Dec 19, 2022 · 0 comments · Fixed by #13187
Assignees
Labels
package:table squad:collaboration Issue to be handled by the Collaboration team. type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@scofalik
Copy link
Contributor

scofalik commented Dec 19, 2022

📝 Provide a description of the improvement

When I was researching performance problems with loading data, I stumbled upon table column resize. The plugin is written in the way that it is very non-performant. The initialization takes a lot of time. For some samples, it crashes with Maximum call stack size exceeded (and it surely shouldn't the sample wasn't that big). For other, it was heavily slowing down the data load (init and paste).

Right now, whenever view is rendered (after every character type, for example) we go through the whole view document tree and check whether some cells are missing a resizer. It's even worse, because whenever we find such cell, we add the resizer ... triggering another render, so we go again... This is why this caused a crash for pasting a huge table but it would also hinder editor UX when there is a lot of content (even with no tables!).

Since we don't have a nice way to check what changed in the view (or I don't remember such way), for efficiency purposes, I propose to add those UI elements on downcast instead. I already wrote a proposal for a solution but I didn't test it thoroughly.

Steps to do are:

  1. Check manually whether it works correctly.
  2. Write/rework unit tests, if needed.
_registerResizerInserter() {
    this.editor.conversion.for( 'editingDowncast' ).add( dispatcher => {
        dispatcher.on( 'insert:tableCell', ( evt, data, conversionApi ) => {
            const mapper = conversionApi.mapper;
            const modelElement = data.item;
            const viewElement = mapper.toViewElement( modelElement );

            if ( !viewElement ) {
                return;
            }

            const viewWriter = conversionApi.writer;
            const viewTableColumnResizerElement = viewWriter.createUIElement( 'div', { class: 'ck-table-column-resizer' } );

            viewWriter.insert(
                viewWriter.createPositionAt( viewElement, 'end' ),
                viewTableColumnResizerElement
            );
        }, { priority: 'lowest' } );
    } );
}
@scofalik scofalik added type:improvement This issue reports a possible enhancement of an existing feature. package:table squad:collaboration Issue to be handled by the Collaboration team. labels Dec 19, 2022
@CKEditorBot CKEditorBot added the status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. label Dec 19, 2022
@CKEditorBot CKEditorBot added status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. and removed status:planned Set automatically when an issue lands in the "Sprint backlog" column. We will be working on it soon. labels Jan 2, 2023
scofalik added a commit that referenced this issue Jan 4, 2023
Other (table): Improved performance when the editor includes table column resize plugin. Closes #13097.
@CKEditorBot CKEditorBot removed the status:in-progress Set automatically when an issue lands in the "In progress" column. We are working on it. label Jan 4, 2023
@CKEditorBot CKEditorBot added this to the iteration 60 milestone Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:table squad:collaboration Issue to be handled by the Collaboration team. type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants