Closed Bug 931191 Opened 11 years ago Closed 11 years ago

Inspector janks for seconds at a time looking at chat.meatspac.es

Categories

(DevTools :: Inspector, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(firefox27 verified, firefox28 verified)

VERIFIED FIXED
Firefox 28
Tracking Status
firefox27 --- verified
firefox28 --- verified

People

(Reporter: jimb, Assigned: bgrins)

References

Details

Attachments

(3 files, 1 obsolete file)

Visit chat.meatspac.es, open the DOM inspector, click on the follow-the-mouse node highlighting, and then mouse over the chat entries. The inspector hangs for seconds at a time.

This may be related to the fact that all the animated images are animated GIFs specified by gigantic data:image/gif;base64 URLs.
We truncate attributes for display, but I don't think we truncate them over the wire.
Attached patch v1Splinter Review
This has three components:

a) Only send partial attributes over the wire, and ask for the full version at edit time.
b) A 'loading' state for the inplace editor, used while asking for the full version.
c) Drastically increase the read length for reading strings, because there was way too much latency getting in the way there.
Assignee: nobody → dcamp
Attachment #824833 - Flags: review?(bgrinstead)
https://tbpl.mozilla.org/?tree=Try&rev=3f1bfaf1f1e2 (I bet something will fail, I wasn't too thorough on local testing).
Comment on attachment 824833 [details] [diff] [review]
v1

Review of attachment 824833 [details] [diff] [review]:
-----------------------------------------------------------------

It speeds up chat.meatspac.es as promised. 

A few notes about the UI:
1) Since the value being sent to the frontend is a max of 50 characters, it is no longer truncated on the frontend.  The COLLAPSE_ATTRIBUTE_LENGTH and COLLAPSE_DATA_URL_LENGTH values should be set to gValueSummaryLength - 1 to reenable the truncation on the frontend.
2) It seems like I've been able to get the editor to stick open sometimes on the meatspac.es site, meaning that it loses focus and won't go away when clicking on another node, pressing escape, etc.  The only way to clear it is to first refocus the input.  I suspect it has to do with the editor loading during a mutation or something, but haven't been able to consistently reproduce (just continuously opening / closing the editor for the src attribute on a gif and it happens sometimes).  Maybe we need to make sure that the promise is being cleaned up in the inplace editor destroy functionality or something?  I will see if I can come up with a more concrete STR.
3) If you inspect a gif near the bottom of the page and double click to open the attribute editor, the markup tree scrolls almost out view and the whole scrollable region becomes huge vertically.  This does seem to be a bug even without the patch applied (albeit without the automatic scrolling) so we can probably figure that out separately.

::: browser/devtools/markupview/markup-view.js
@@ +1663,5 @@
>      };
>      this.template("attribute", data);
>      var {attr, inner, name, val} = data;
>  
> +    let self = this;

`self` isn't used here, can be removed

::: browser/devtools/markupview/test/browser_bug896181_css_mixed_completion_new_attribute.js
@@ +12,5 @@
>  
>  function test() {
>    let inspector;
>    let {
> +    getLoadedInplaceEditorForSpan: inplaceEditor

please import variable this as `loadedInplaceEditor` for both tests, to help distinguish between the `inplaceEditor` function used in other tests.

::: toolkit/devtools/server/actors/inspector.js
@@ +226,5 @@
> +        value: attr.value.substring(0, gValueSummaryLength),
> +        incomplete: true
> +      }
> +    }
> +    return attr.substring(0, 50);

Extra return statement that never gets executed
Attachment #824833 - Flags: review?(bgrinstead)
(In reply to Brian Grinstead [:bgrins] from comment #4)

> 1) Since the value being sent to the frontend is a max of 50 characters, it
> is no longer truncated on the frontend.  The COLLAPSE_ATTRIBUTE_LENGTH and
> COLLAPSE_DATA_URL_LENGTH values should be set to gValueSummaryLength - 1 to
> reenable the truncation on the frontend.

Assuming 120 chars was chosen for a reason, should we truncate attrs at 120 instead of 50 in the protocol?

> 3) If you inspect a gif near the bottom of the page and double click to open
> the attribute editor, the markup tree scrolls almost out view and the whole
> scrollable region becomes huge vertically.  This does seem to be a bug even
> without the patch applied (albeit without the automatic scrolling) so we can
> probably figure that out separately.

Yeah, let's split that out.
(In reply to Dave Camp (:dcamp) from comment #5)
> (In reply to Brian Grinstead [:bgrins] from comment #4)
> 
> > 1) Since the value being sent to the frontend is a max of 50 characters, it
> > is no longer truncated on the frontend.  The COLLAPSE_ATTRIBUTE_LENGTH and
> > COLLAPSE_DATA_URL_LENGTH values should be set to gValueSummaryLength - 1 to
> > reenable the truncation on the frontend.
> 
> Assuming 120 chars was chosen for a reason, should we truncate attrs at 120
> instead of 50 in the protocol?
> 

The number was somewhat arbitrarily chosen as what was a couple of lines of wrapping.  But yes, if that won't negatively affect performance in other cases, it would be good to keep it at what we had decided earlier (this will also allow data URLs to get collapsed earlier than normal attribute values as originally designed).  Although I believe we will have to either set this one at 121 or set COLLAPSE_ATTRIBUTE_LENGTH at 119 in order to trigger the actual ellipses.
(In reply to Brian Grinstead [:bgrins] from comment #6)
> (In reply to Dave Camp (:dcamp) from comment #5)
> > (In reply to Brian Grinstead [:bgrins] from comment #4)
> > 
> > > 1) Since the value being sent to the frontend is a max of 50 characters, it
> > > is no longer truncated on the frontend.  The COLLAPSE_ATTRIBUTE_LENGTH and
> > > COLLAPSE_DATA_URL_LENGTH values should be set to gValueSummaryLength - 1 to
> > > reenable the truncation on the frontend.
> > 
> > Assuming 120 chars was chosen for a reason, should we truncate attrs at 120
> > instead of 50 in the protocol?
> > 
> 
> The number was somewhat arbitrarily chosen as what was a couple of lines of
> wrapping.  But yes, if that won't negatively affect performance in other
> cases, it would be good to keep it at what we had decided earlier (this will
> also allow data URLs to get collapsed earlier than normal attribute values
> as originally designed).  Although I believe we will have to either set this
> one at 121 or set COLLAPSE_ATTRIBUTE_LENGTH at 119 in order to trigger the
> actual ellipses.

We could rework the ellipses to be based on whether the protocol tells us it had to truncate or not.
(In reply to Dave Camp (:dcamp) from comment #7)
> (In reply to Brian Grinstead [:bgrins] from comment #6)
> > (In reply to Dave Camp (:dcamp) from comment #5)
> > > (In reply to Brian Grinstead [:bgrins] from comment #4)
> > > 
> > > > 1) Since the value being sent to the frontend is a max of 50 characters, it
> > > > is no longer truncated on the frontend.  The COLLAPSE_ATTRIBUTE_LENGTH and
> > > > COLLAPSE_DATA_URL_LENGTH values should be set to gValueSummaryLength - 1 to
> > > > reenable the truncation on the frontend.
> > > 
> > > Assuming 120 chars was chosen for a reason, should we truncate attrs at 120
> > > instead of 50 in the protocol?
> > > 
> > 
> > The number was somewhat arbitrarily chosen as what was a couple of lines of
> > wrapping.  But yes, if that won't negatively affect performance in other
> > cases, it would be good to keep it at what we had decided earlier (this will
> > also allow data URLs to get collapsed earlier than normal attribute values
> > as originally designed).  Although I believe we will have to either set this
> > one at 121 or set COLLAPSE_ATTRIBUTE_LENGTH at 119 in order to trigger the
> > actual ellipses.
> 
> We could rework the ellipses to be based on whether the protocol tells us it
> had to truncate or not.

Never mind, that doesn't seem like it'll work.  I'll set COLLAPSE_ATTRIBUTE_LENGTH to 119 and send 120 characters.
Of course, that'll leave us ellipsing a truncated-at-the-end value in the middle.
OK, so the addition of the output parser and truncation makes this more complicated than I hoped it would be.

We can do some truncation on the server side, but without doing the entire output parser on the server side, it's not going to be as good as it is now.  I don't feel great doing the entire output parser on the server, but maybe that's the way to go.

Thoughts?
hrm.  Local transport, where this is breaking, shouldn't be adding significant transport overhead.  So this might not even be the right problem to be solving.

Maybe the output parser is slow?
This needs more attention than I can give it right now.  Maybe bgrins or mratcliffe can profile and see what's taking too much time?
Assignee: dcamp → nobody
(In reply to Dave Camp (:dcamp) from comment #11)
> hrm.  Local transport, where this is breaking, shouldn't be adding
> significant transport overhead.  So this might not even be the right problem
> to be solving.
> 
> Maybe the output parser is slow?

This patch definitely seems to be addressing the performance issue.  Are you thinking this is just because you increased the LONG_STRING_READ_LENGTH?
Attached patch bypass-output-parser.diff (obsolete) — Splinter Review
But this fixes the performance problem too, even without any protocol changes.
(I do think we should increase LONG_STRING_READ_LENGTH though)
(In reply to Dave Camp (:dcamp) from comment #14)
> Created attachment 827082 [details] [diff] [review]
> bypass-output-parser.diff
> 
> But this fixes the performance problem too, even without any protocol
> changes.

Mike, looks like the output parser is causing a slowdown on very long attributes.  Mind taking a look at it?  You can see it by inspecting one of the gifs on chat.meatspac.es with and without Attachment 827082 [details] [diff] applied.
Flags: needinfo?(mratcliffe)
I am surprised that there is such a slowdown but I can see why. The current output parser didn't parse URLs so it will parse the URL text in chunks, which would cause a significant slowdown if you have a lot of long data URLs.

The parser was simplified and to a large extent rewritten for bug 929384 but I need to address Patrick's comments before it lands.

This bug really needs to wait on that change, setting as dependent on bug 929384.
Depends on: 929384
Flags: needinfo?(mratcliffe)
Mike,
Can you have a look at this patch?  It does two things to the output parser:

1) It sets a MAX_ITERATIONS constant which upon being reached, will dump the rest of the text into a text node and end the loop.
2) It changes the intermediate storage in this.parsed for text nodes in to be strings instead, which also seems to speed things up (I think in this particular case the `lastItem.nodeValue += text` was getting slow because there were so many iterations (around 26K on one gif I tested).

I realize that this particular case will also be handled by the URL matching in Bug 929384, but we should prevent this kind of slowdown from any input (even if it isn't a data URL).

Pushed to try: https://tbpl.mozilla.org/?tree=Try&rev=68f7535f051e
Assignee: nobody → bgrinstead
Attachment #827082 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #827464 - Flags: review?(mratcliffe)
Comment on attachment 827464 [details] [diff] [review]
speedup-output-parser.patch

Review of attachment 827464 [details] [diff] [review]:
-----------------------------------------------------------------

Very simple idea to use a string instead of a text node ... I like it.

100 iterations seems a little high but I guess we should leave it there for the moment.
Attachment #827464 - Flags: review?(mratcliffe) → review+
Think this is still worth doing?
Attachment #828291 - Flags: review?(dcamp)
https://hg.mozilla.org/mozilla-central/rev/1238b4fee5b5
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 28
Attachment #828291 - Flags: review?(dcamp) → review+
Attachment #827464 - Flags: checkin+
Attachment #828291 - Flags: checkin?
Whiteboard: [fixed-in-fx-team]
Comment on attachment 827464 [details] [diff] [review]
speedup-output-parser.patch

We need to uplift this in order to land bug 939098, which is already approved.

[Approval Request Comment]
Bug caused by (feature/regressing bug #): DevTools output parser
User impact if declined: Class names in markup panel may be replaced by color swatches e.g. class="red" would be displayed as class="#F00", class="inherit" would be displayed as class="black", CSS shortcut properties such as border: 1px solid red will not receive color swatches plus various other issues.
Testing completed (on m-c, etc.): Yes
Risk to taking this patch (and alternatives if risky): Low
String or IDL/UUID changes made by this patch: None
Attachment #827464 - Flags: approval-mozilla-aurora?
Attachment #827464 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
https://hg.mozilla.org/releases/mozilla-aurora/rev/ff70754e42bc

Calling this "fixed" on Fx27 for tracking purposes, but I recognize that only one patch from this bug landed on it.
Keywords: verifyme
Verified as fixed on Ubuntu 12.10 x86_64 using the 01/16 Firefox 28.

It also works a lot better on Firefox 27 (verified on beta 7), though it's somewhat slower than 28.
Status: RESOLVED → VERIFIED
Keywords: verifyme
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: