Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Efficiently store computed style data #17

Closed
gunesacar opened this issue Oct 25, 2018 · 4 comments
Closed

Efficiently store computed style data #17

gunesacar opened this issue Oct 25, 2018 · 4 comments

Comments

@gunesacar
Copy link
Collaborator

We plan to use computed style in the clustering stage. But storing multiple snapshots of elements' style can be too much, especially in cases like fade in or similar effects, where the style is updated every few milliseconds.

We can consider storing only non-default style values, something like: https://stackoverflow.com/questions/22907735/get-the-computed-style-and-omit-defaults

@gunesacar
Copy link
Collaborator Author

gunesacar commented Oct 26, 2018

Here is how I plan to do this: http://jsfiddle.net/ba80ehnv/1/
We'll store the diff of computed style and default style.

The code is not optimized at the moment, we can obviously memoize or precompute default style lookups.
@aruneshmathur does it look good to you?

One further optimization would be to exclude CSS properties like perspective-origin which seem to change values based on element dimensions.

@gunesacar
Copy link
Collaborator Author

This is added in gunesacar/OpenWPM@568a852
It looks like we have to optimize the part where we compare default element style to computed style. It takes around 15ms, and 50% of total CPU time (as reported by Devtool's Performance measurement)

@gunesacar
Copy link
Collaborator Author

We've decided against storing all style information; instead we'll handpick more basic style attributes like text color, background color, text size etc.

@gunesacar gunesacar self-assigned this Nov 3, 2018
@gunesacar
Copy link
Collaborator Author

We got a ~10x speed increase by limiting ourselves to CSSStyleDeclaration interface (=275 declarations) instead of iterating over it as an ordinary object (~1200 declarations+naming variations):
gunesacar/OpenWPM@36b0922

This is much better than hand-picking style values as we now store all style info. Closing...

@gunesacar gunesacar removed their assignment Feb 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant