codex-team / codex-team/editor.js

Mutation observer for "onChange" event is re-enabled to early when loading large document

Open
#2,867 2 comments 0 reactions 0 assignees View on GitHub
bug important
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

When replacing the editor contents by calling "render()" the MutationObserver that detects changes should be deactivated and reactivated after the new content has been rendered. It seems the async render() method just uses a 2000ms timer, so when a document takes longer to render the MutationObserver is re-enabled too early and there are hundreds of calls to "isMutationBelongsToElement()" that bay continue multiple seconds and creating 100% cpu load.

Steps to reproduce:
1. load a document using render()
2. load another very lange document using render()
3. look at the Chrome performance monitor or record a performance profile and look at the many calls.

Expected behavior:
when rendering a new document the Editor makes sure that the new content has been fully rendered before re-activating the MutationObserver.

Editor.js version:
2.30.6

Plugins you use with their versions:
not relevant

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.