Page MenuHomePhabricator

CodeMirror 6 MediaWiki stream parser produces excess markup
Closed, ResolvedPublicBUG REPORT

Description

Background

In working on T348019: Port MediaWiki mode to CodeMirror 6 stream-parser, I have hit a wall with one particular issue where identical adjacent tokens unnecessarily have separate <span> tags. This does not visually produce any issue, but the excess markup could pose a performance problem.

I tried reproducing the issue with CodeMirror 6's "Try" feature, but in doing so I believe I have concluded this is not an issue with CM6 but with my code.

Steps to replicate the issue (include links if applicable):

  • Check out r972438
  • Start a new page with CM6 enabled (i.e. ?cm6enable=1)
  • Add only the content https://wikimedia.org

What happens?:

The markup is as follows:

<div class="cm-line">
  <span class="cm-mw-free-extlink-protocol">https://</span>
  <span class="cm-mw-free-extlink">wikimedia.</span>
  <span class="cm-mw-free-extlink">org</span>
</div>

What should have happened instead?:

The markup should be:

<div class="cm-line">
  <span class="cm-mw-free-extlink-protocol">https://</span>
  <span class="cm-mw-free-extlink">wikimedia.org</span>
</div>

Software version

CodeMirror with r972438 checked out

Other information (browser name/version, screenshots, etc.):

The above is just one example. This happens in many cases, such as table headings:

{| class="wikitable"

produces:

<div class="cm-line">
  <span class="cm-mw-table-bracket">{|</span>
  <span class="cm-mw-table-definition">class</span>
  <span class="cm-mw-table-definition">="wikitable"</span>
</div>

There should be just one span for .cm-mw-table-definition.

Details

Related Changes in Gerrit:

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

It is not a fair comparison. If we try to faithfully reproduce the eatFreeExternalLink on the CodeMirror 6 website (demo), a similar issue occurs.

I think it's still an issue with our code. Or at least, other legacy stream parsers don't seem to have this issue.

Overall though, after seeing how fast CodeMirror 6 is even with the extra markup, I'm thinking it may not be a *must* for the CM6 upgrade project. But I definitely want to investigate more before giving up.

Not a blocker for rolling out CM6, but this should be revisited at some point.

It never hurts to ask the maintainers, right?! https://discuss.codemirror.net/t/streamparser-can-produce-excess-markup/8770

This is now fixed upstream. I'll look into this at a later time, since it will require a bump to the language package which may require other packages to be bumped (see also T358804#10065810).

Change #1100834 had a related patch set uploaded (by Bhsd; author: Bhsd):

[mediawiki/extensions/CodeMirror@master] build: Updating codemirror

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

Change #1100834 merged by jenkins-bot:

[mediawiki/extensions/CodeMirror@master] build: Updating codemirror

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

I guess the bidi isolation may not work properly after this change, and I will look into it later. By the way, is the bidi isolation enabled anywhere among the WMF projects?

I guess the bidi isolation may not work properly after this change, and I will look into it later. By the way, is the bidi isolation enabled anywhere among the WMF projects?

No, it is not available anywhere unless you pass in ?cm6bidi=1. I have not had time to revisit T358804. Indeed the newer CodeMirror packages supposedly have better bidi support, possibly invalidating the work we did before.

Bhsd claimed this task.
Bhsd moved this task from Bugs to Done on the MediaWiki-extensions-CodeMirror board.