Closed
Bug 962857
Opened 11 years ago
Closed 11 years ago
Debugger mistakenly thinks that many chrome js(m) files are minified and pretty prints them
Categories
(DevTools :: Debugger, defect, P3)
Tracking
(Not tracked)
RESOLVED
FIXED
Firefox 30
People
(Reporter: anton, Assigned: b4bomsy)
Details
Attachments
(2 files, 1 obsolete file)
1.44 KB,
patch
|
rcampbell
:
review+
past
:
checkin+
|
Details | Diff | Splinter Review |
2.36 KB,
patch
|
Details | Diff | Splinter Review |
If you open Browser Toolbox > Debugger and select profiler/controller.js, Debugger thinks that the source if minified and tries to pretty-print it. Since the source has ES6 constructions in it, it fails producing invalid code.
Comment 1•11 years ago
|
||
Yeah, we shouldn't be pretty printing that file by default since it definitely isn't minified.
Summary: Debugger thinks that profiler/controller.js is pretty-printed → Debugger mistakenly thinks that profiler/controller.js is minified and pretty prints it
Assignee | ||
Comment 2•11 years ago
|
||
I'll look into it.
Thanks
Assignee | ||
Comment 3•11 years ago
|
||
i think increasing the SAMPLE_SIZE will fix this, we are using 30 lines as the sample size ATM and because those 30 lines are mostly declaration statements (therefore no indents) the heuristics fails.
Pls could this assign this to me, So it comes on my bugmotodo list to fix? thanks
Comment 5•11 years ago
|
||
Note that this is not just one file, but most of the chrome js(m) files.
Summary: Debugger mistakenly thinks that profiler/controller.js is minified and pretty prints it → Debugger mistakenly thinks that many chrome js(m) files are minified and pretty prints them
Assignee | ||
Comment 6•11 years ago
|
||
(In reply to Girish Sharma [:Optimizer] from comment #5)
> Note that this is not just one file, but most of the chrome js(m) files.
Yeah i noticed, most of these files have the same structure. thanks
Comment 7•11 years ago
|
||
Perhaps looking at the last n lines would give us better results than looking at the first n lines and wouldn't require iterating over more of each source.
Assignee | ||
Comment 8•11 years ago
|
||
(In reply to Nick Fitzgerald [:fitzgen] from comment #7)
> Perhaps looking at the last n lines would give us better results than
> looking at the first n lines and wouldn't require iterating over more of
> each source.
That's a tot?
There is also the situation to consider where the file might contain only declarations.
I'm thinking of adding a check on the line length as well. What do think?
.
Reporter | ||
Comment 9•11 years ago
|
||
What about comparing the average length of a line with the average line count? Minified files have less lines but each one of them is longer than usual.
Comment 10•11 years ago
|
||
(In reply to Anton Kovalyov (:anton) from comment #9)
> What about comparing the average length of a line with the average line
> count? Minified files have less lines but each one of them is longer than
> usual.
Probably a reliable hueristic, but the downside is that we would have to look over the whole source instead of just a small constant number of lines in it.
Would also have to be careful of the edge cases that break median and mode line length I described here: https://bugzilla.mozilla.org/show_bug.cgi?id=913665#c2
Comment 11•11 years ago
|
||
We are branching on Monday and too many people are affected. Let's disable auto-pretty-print by default for now until we fix this.
Attachment #8368610 -
Flags: review?(rcampbell)
Updated•11 years ago
|
Assignee: b4bomsy → past
Updated•11 years ago
|
Attachment #8368610 -
Flags: review?(rcampbell) → review+
Comment 12•11 years ago
|
||
Whiteboard: [fixed-in-fx-team][leave open]
Comment 14•11 years ago
|
||
The pref change broke the auto-pretty-print tests, because they assumed the pref would be enabled by default. I pushed a change to make them work regardless of the actual default value:
https://hg.mozilla.org/integration/fx-team/rev/82e30c1856ee
Comment 15•11 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/777869c35c0d
https://hg.mozilla.org/mozilla-central/rev/82e30c1856ee
Flags: in-testsuite+
Whiteboard: [fixed-in-fx-team][leave open] → [leave open]
Updated•11 years ago
|
Attachment #8368610 -
Flags: checkin+
Assignee | ||
Comment 16•11 years ago
|
||
This patch fixes the false detection of .jsm files as minified and handles files which may not have indents but are not actually minified (e.g files containing just variable declarations)
Attachment #8391781 -
Flags: review?(nfitzgerald)
Comment 17•11 years ago
|
||
Comment on attachment 8391781 [details] [diff] [review]
962857fix.patch
Review of attachment 8391781 [details] [diff] [review]:
-----------------------------------------------------------------
LGTM! Fix up the nits, reattach, and mark "checkin-needed"!
::: browser/devtools/debugger/debugger-panes.js
@@ +8,5 @@
>
> // Used to detect minification for automatic pretty printing
> +const SAMPLE_SIZE = 50; // no of lines
> +const INDENT_COUNT_THRESHOLD = 5; // percentage
> +const CHARACTER_LIMIT = 250; // line character limit
Nit: trailing space.
@@ +1513,5 @@
> }
> if (/^\s+/.test(aText.slice(lineStartIndex, lineEndIndex))) {
> indentCount++;
> }
> + // For files with no indents but are not minified.
Nit: trailing space.
@@ +1515,5 @@
> indentCount++;
> }
> + // For files with no indents but are not minified.
> + if ((lineEndIndex - lineStartIndex) > CHARACTER_LIMIT) {
> + overCharLimit = true;
We can break iteration here as well because if a single line is over the character limit we consider the source minified. No need to keep checking other lines.
Attachment #8391781 -
Flags: review?(nfitzgerald) → review+
Assignee | ||
Comment 18•11 years ago
|
||
(In reply to Nick Fitzgerald [:fitzgen] from comment #17)
> Comment on attachment 8391781 [details] [diff] [review]
> 962857fix.patch
>
> Review of attachment 8391781 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> LGTM! Fix up the nits, reattach, and mark "checkin-needed"!
>
> ::: browser/devtools/debugger/debugger-panes.js
> @@ +8,5 @@
> >
> > // Used to detect minification for automatic pretty printing
> > +const SAMPLE_SIZE = 50; // no of lines
> > +const INDENT_COUNT_THRESHOLD = 5; // percentage
> > +const CHARACTER_LIMIT = 250; // line character limit
>
> Nit: trailing space.
>
> @@ +1513,5 @@
> > }
> > if (/^\s+/.test(aText.slice(lineStartIndex, lineEndIndex))) {
> > indentCount++;
> > }
> > + // For files with no indents but are not minified.
>
> Nit: trailing space.
>
> @@ +1515,5 @@
> > indentCount++;
> > }
> > + // For files with no indents but are not minified.
> > + if ((lineEndIndex - lineStartIndex) > CHARACTER_LIMIT) {
> > + overCharLimit = true;
>
> We can break iteration here as well because if a single line is over the
> character limit we consider the source minified. No need to keep checking
> other lines.
Thanks.. nick.
My war against trailing spaces, started it has (yoda voice)..
Assignee | ||
Comment 19•11 years ago
|
||
Attachment #8391781 -
Attachment is obsolete: true
Assignee | ||
Updated•11 years ago
|
Keywords: checkin-needed
Comment 20•11 years ago
|
||
Keywords: checkin-needed
Whiteboard: [leave open] → [leave open][fixed-in-fx-team]
Comment 21•11 years ago
|
||
Whiteboard: [leave open][fixed-in-fx-team] → [leave open]
Comment 22•11 years ago
|
||
Any reason for having this as [leave open] still ?
Comment 23•11 years ago
|
||
Don't think so!
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Updated•11 years ago
|
Whiteboard: [leave open]
Updated•11 years ago
|
Target Milestone: --- → Firefox 30
Updated•11 years ago
|
QA Whiteboard: [qa-]
Updated•7 years ago
|
Product: Firefox → DevTools
You need to log in
before you can comment on or make changes to this bug.
Description
•