New issue
Advanced search Search tips

Issue 628785 link

Starred by 2 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Setting inline style spends 10% of time in LookupIterator due to missing attribute handlers

Project Member Reported by esprehn@chromium.org, Jul 15 2016

Issue description

This was the result of implementing some strange read through behavior in the spec:
http://heycam.github.io/webidl/#OverrideBuiltins

but it produces some crazy results, ex.

Object.prototype.color = "wtf";

makes *every* style object in the entire document report "wtf" for the color property.

ex.
document.createElement("div").style.color == "wtf"

This perf regression was reported by the bots but marked as WontFix which is not right:
https://bugs.chromium.org/p/chromium/issues/detail?id=478105

our behavior here doesn't match the CSSOM spec either, the spec says that we're supposed to have getters and setters on the CSSStyleDeclaration object not do this crazy read through behavior (which no other browser is doing).
See https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-5


 
Status: Assigned (was: Asss)
Cc: domenic@chromium.org verwa...@chromium.org adamk@chromium.org
A profile of the JS execution time in CSS/CSSPropertyUpdateValue.html benchmark reports:

Running Time	Self (ms)		Symbol Name
10986.0ms   11.1%	577.0	 	     v8::internal::LookupIterator::PropertyOrElement(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, bool*, v8::internal::LookupIterator::Configuration)

which means that DOM code that's setting inline styles for animations took a 10% perf hit by this change. We need to revert this change, or switch to following the spec and have real getter/setters or something. Right now Chrome matches neither Firefox, Safari or Edge.

This read through behavior in general is very strange, it seems pretty broken that setting a value on Object.prototype would break all of the instance interceptors.

ex. 

Object.prototype.test = "wtf";
localStorage.setItem("test", "should be test")
localStorage.test == "wtf";

but

Object.getOwnPropertyDescriptor(localStorage, "test").value == "should be test"

so JS is telling you the instance has this property, but setter/getting it always goes up the prototype chain. Technically Proxies are capable of this behavior, but it's super confusing, and results in a 10% performance slowdown on *everything* that has an interceptor.
Labels: Performance
Hmm so I can see why localStorage wants this:

localStorage.setItem("setItem", "10")
localStorage.setItem == Storage.prototype.setItem;

though the spec does result in some confusing behavior:

// Actually sets a data property, since hasOwnProperty is on the prototype chain.
localStorage.hasOwnProperty = "test";
localStorage.getItem("hasOwnProperty") == undefined

In either case CSSStyleDeclaration isn't supposed to use an interceptor and do named lookup like localStorage at all, so Chrome isn't following any spec with it's current behavior.

We should probably switch to having actual getter/setters so we at least follow the spec, and also so we don't take the 10% perf hit.
Owner: timloh@chromium.org
timloh@, could you triage this issue?  I think this is an issue of core/css/, at least it's CSS team who made a decision to implement CSS attributes as named properties.

Comment 5 by timloh@chromium.org, Jul 27 2016

Cc: yukishiino@chromium.org
These have been named properties forever*. What's the correct way to implement these?

* https://chromium.googlesource.com/chromium/src/+/b6cf53%5E%21/
Per the original report at #0, I suppose the following is the spec to be implemented.
https://drafts.csswg.org/cssom/#ref-for-cssstyledeclaration-5

Then, each _camel_cased_attribute must be an ordinary regular DOM attribute.  You should list all of them up in the .idl file.

Seeing the definition of CSSStyleDeclaration interface as below,
https://drafts.csswg.org/cssom/#cssstyledeclaration
CSSStyleDeclaration interface must not support named properties (though it supports indexed properties).

Owner: ----
Status: Available (was: Assigned)
I haven't had time to look into this, unassigning myself.

Comment 8 by shans@chromium.org, Nov 18 2016

Components: -Blink>Bindings
Owner: meade@chromium.org
Status: Assigned (was: Available)
Labels: Update-Quarterly
Labels: -Pri-1 Pri-2
It sounds like this isn't really P1. Dropping priority.

Comment 11 by meade@chromium.org, Jul 12 2017

Cc: meade@chromium.org
Owner: ----
Status: Available (was: Assigned)
I'm not really sure why this was assigned to me... I'm not likely to work on it any time soon so removing myself.

Comment 12 by shend@chromium.org, Oct 31 2017

Labels: BlockedBug Standards Hotlist-Interop
Seems like this is now an interop issue because we're not conforming to a spec?
Labels: -Update-Quarterly
Project Member

Comment 14 by sheriffbot@chromium.org, Dec 6

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: -yukishiino@chromium.org -meade@chromium.org -domenic@chromium.org -adamk@chromium.org -haraken@chromium.org -verwa...@chromium.org andruud@chromium.org
Status: Available (was: Untriaged)

Sign in to add a comment