Bug 168253 - Web Inspector: CodeMirror doesn't highlight the full text if it is on a single line
Summary: Web Inspector: CodeMirror doesn't highlight the full text if it is on a singl...
Status: RESOLVED WONTFIX
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Devin Rousso
URL: http://devinrousso.com
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-13 14:05 PST by Devin Rousso
Modified: 2017-02-14 19:21 PST (History)
3 users (show)

See Also:


Attachments
[Image] Screenshot of Issue (802.24 KB, image/png)
2017-02-13 14:05 PST, Devin Rousso
no flags Details
Patch (1.58 KB, patch)
2017-02-13 14:16 PST, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Devin Rousso 2017-02-13 14:05:24 PST
Created attachment 301388 [details]
[Image] Screenshot of Issue

This seems to be controlled by <http://codemirror.net/3/doc/manual.html#option_maxHighlightLength>.
Comment 1 Devin Rousso 2017-02-13 14:16:19 PST
Created attachment 301389 [details]
Patch
Comment 2 Matt Baker 2017-02-13 14:34:41 PST
Could you includes steps to reproduce? The screenshot without context doesn't illustrate the issue.
Comment 3 Joseph Pecoraro 2017-02-13 19:07:30 PST
Comment on attachment 301389 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301389&action=review

> Source/WebInspectorUI/UserInterface/Views/TextEditor.js:45
> +            maxHighlightLength: Infinity,

I think we should only make this infinity if we have line wrapper. If we don't have line wrapping it ends up being a huge performance problem. (And maybe then we should make it something like 2000 instead of the 10000 that is the default).
Comment 4 Devin Rousso 2017-02-13 21:27:01 PST
Comment on attachment 301389 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=301389&action=review

>> Source/WebInspectorUI/UserInterface/Views/TextEditor.js:45
>> +            maxHighlightLength: Infinity,
> 
> I think we should only make this infinity if we have line wrapper. If we don't have line wrapping it ends up being a huge performance problem. (And maybe then we should make it something like 2000 instead of the 10000 that is the default).

Based on what I can see in the CodeMirror source, I don't think setting changing the maxHighlightLength really effects much.  It seems to only apply to how much of a single line is processed for syntax highlighting, not the entire file.  As such, checking if line wrapping is enabled seems to be unnecessary.
<https://github.com/codemirror/CodeMirror/search?q=maxHighlightLength>
Comment 5 Devin Rousso 2017-02-13 21:29:06 PST
(In reply to comment #2)
> Could you includes steps to reproduce? The screenshot without context
> doesn't illustrate the issue.

1. Go to <http://devinrousso.com>
2. Open WebInspector to the Resources tab
3. Select "common.css" in the navigation sidebar
4. Scroll down in that file (or until you find ".spinner")
Comment 6 Devin Rousso 2017-02-13 21:30:28 PST
(In reply to comment #5)
> (In reply to comment #2)
> > Could you includes steps to reproduce? The screenshot without context
> > doesn't illustrate the issue.
> 
> 1. Go to <http://devinrousso.com>
> 2. Open WebInspector to the Resources tab
> 3. Select "common.css" in the navigation sidebar
> 4. Scroll down in that file (or until you find ".spinner")

5. Disable Pretty Print

Sorry, forgot that step :P
Comment 7 Joseph Pecoraro 2017-02-14 11:32:23 PST
(In reply to comment #4)
> Comment on attachment 301389 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=301389&action=review
> 
> >> Source/WebInspectorUI/UserInterface/Views/TextEditor.js:45
> >> +            maxHighlightLength: Infinity,
> > 
> > I think we should only make this infinity if we have line wrapper. If we don't have line wrapping it ends up being a huge performance problem. (And maybe then we should make it something like 2000 instead of the 10000 that is the default).
> 
> Based on what I can see in the CodeMirror source, I don't think setting
> changing the maxHighlightLength really effects much.  It seems to only apply
> to how much of a single line is processed for syntax highlighting, not the
> entire file.  As such, checking if line wrapping is enabled seems to be
> unnecessary.
> <https://github.com/codemirror/CodeMirror/search?q=maxHighlightLength>

Okay. It should be trivial to test this. With your existing test case (or one that is much larger like say 50000 characters), set highlight length to 2000 or Infinity and gauge how long it feels with line wrapping disabled. If it really does look/feel the same then I'm sold. But in the past this (or something related) was the cause of hangs in Web Inspector. The search link you provide shows a highlight_worker so it is possible things have changed.
Comment 8 Devin Rousso 2017-02-14 18:19:09 PST
(In reply to comment #7)
> Okay. It should be trivial to test this. With your existing test case (or
> one that is much larger like say 50000 characters), set highlight length to
> 2000 or Infinity and gauge how long it feels with line wrapping disabled. If
> it really does look/feel the same then I'm sold. But in the past this (or
> something related) was the cause of hangs in Web Inspector. The search link
> you provide shows a highlight_worker so it is possible things have changed.

OK I think I misunderstood what your point was.  Yes, the maxHighlightLength does affect the performance of CodeMirror, and the lower the value the faster it renders.  What I was trying to say was that changing this value only affects the syntax highlighting on a single line, and that changing this value doesn't affect shorter lines.  If line wrapping and pretty print are both disabled, however, there is a noticeable worsening of the performance of larger files.  In light of this, I think your point is valid and we shouldn't make this change.