Page MenuHomePhabricator

Syntax Highlighter consumes huge amounts of CPU on large texts or on mobile phone.
Closed, InvalidPublic

Description

The Syntax Highlighter is an amazing gadget, but one thing that I have constantly suffered from is the script running on large pages or my mobile phone.

The current version of the syntax highlighter runs through the text area on every keystroke. This is highly problematic on larger pages or phone editing as the typing gets slowed down. The result is that a user types something and has to wait until the sentence gets typed out as the highlighter steps in on every character being inserted. During that process I've seen the browser process consume quite a generous amount of CPU resources on my computer, and on my phone the CPU gets maxed out.

I propose one of the following two solutions:

  1. Have the highlighter wait until 1.5 seconds after the last key stroke to process the page. That means the highlighter remains idle until the user has finished typing thus the highlighter will not block the text field as a user types. It's pointless to process highlighting while the user types.
  2. Have the highlighter come with options to disable highlighting when the page size goes beyond a certain threshold or initial processing time takes too long. The run time threshold option should be in milli or micro seconds.

This will go a long way to making the highlighter not kill performance on a mobile phone.

data

Event Timeline

Syntax highlighting is not meant to be used on mobile yet. It might be integrated with mobile frontend editor at some point but if you are using the desktop site on mobile, you will run into this problem.

Niharika removed a project: Community-Tech.
Vvjjkkii renamed this task from Syntax Highlighter consumes insane amounts of CPU on large texts or on mobile phone. to 5saaaaaaaa.Jul 1 2018, 1:03 AM
Vvjjkkii removed MusikAnimal as the assignee of this task.
Vvjjkkii raised the priority of this task from Low to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii edited subscribers, added: MusikAnimal; removed: Aklapper.
Cyberpower678 renamed this task from 5saaaaaaaa to Syntax Highlighter consumes insane amounts of CPU on large texts or on mobile phone..Jul 1 2018, 2:08 PM
Cyberpower678 assigned this task to MusikAnimal.
Cyberpower678 lowered the priority of this task from High to Low.
Cyberpower678 updated the task description. (Show Details)
Cyberpower678 added a project: Mobile.
Cyberpower678 edited subscribers, added: Aklapper; removed: MusikAnimal.

Change 574855 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/CodeMirror@master] Improve render performance of CodeMirror

https://gerrit.wikimedia.org/r/574855

This might be related to the bug I found and fixed in T270317#6740027.

Change 574855 abandoned by TheDJ:

[mediawiki/extensions/CodeMirror@master] Improve render performance of CodeMirror

Reason:

https://gerrit.wikimedia.org/r/574855

This also affects desktops with a table large enough, say 300 KB, so it's not mobile only. Under those circumstances the extension is virtually unusable.

This also affects desktops with a table large enough, say 300 KB, so it's not mobile only.

Could you provide a link to an example?

Reedy renamed this task from Syntax Highlighter consumes insane amounts of CPU on large texts or on mobile phone. to Syntax Highlighter consumes huge amounts of CPU on large texts or on mobile phone..Jan 31 2025, 12:51 AM
Reedy updated the task description. (Show Details)

CodeMirror 5 has officially been retired, thus closing as invalid. Please re-open or file a new bug should the issue persist with the new version.