matrix-org / matrix-rich-text-editor

Matrix Rich Text Editor
https://matrix-org.github.io/matrix-rich-text-editor/
Apache License 2.0
92 stars 23 forks source link

Expensive HTML parser setup runs on each key press in Android #887

Open jonnyandrew opened 10 months ago

jonnyandrew commented 10 months ago

Problem

On Android, an expensive HTML parser setup operation runs on each key press. This contributes to slow/laggy typing experience which is particularly visible in debug builds.

Proposed solution

Currently, each time the composer model changes, the Android platform code creates a new instance of HtmlToSpansParser which in turn creates a new instance of Parser. This newly initialised Parser then runs an expensive setup operation because it has not parsed any content before.

Improve the efficiency of the editor by holding a reference to some of these objects and reusing them.