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

Chrome lags on cursor changes #275

Closed
jonathanolson opened this issue Sep 2, 2014 · 23 comments
Closed

Chrome lags on cursor changes #275

jonathanolson opened this issue Sep 2, 2014 · 23 comments

Comments

@jonathanolson
Copy link
Contributor

FPAF and other sims show this.

@jonathanolson
Copy link
Contributor Author

Also a problem in ESPB during animation.

@jonathanolson
Copy link
Contributor Author

Didn't find any issues in Chromium bug tracker.

@jonathanolson
Copy link
Contributor Author

I found no direct solutions or workarounds, and didn't find any public reports of this in Chrome (Googling, or in the Chromium issue tracker).

It seems that the style and layout computations are re-done even if we add an overlay meant just for the events.

Notably in the screenshot below, this is triggering over all of the nodes in the SVG tree whenever the cursor changes. I'd highly recommend combining many line/path elements into a single path (see GridNode, GaugeNode), and minimizing the number of nodes (it's reflowing the invisible ones also). I see ToggleButtonDeprecated with 4 copies of things. The Scene when loaded in the 1st tab has ~1320 nodes in the tree (including all screens), so I'd recommend testing with the add/remove child for screens instead of visibility toggles to see if that helps.

scenery-layout

Also, we probably want to open a Chromium issue for this.

@samreid
Copy link
Member

samreid commented Sep 9, 2014

I tried launching ESPB with ?standalone, and it seems like the problem reduced by about 70%, so I think @jonathanolson hypothesis is correct. This seems like another opportunity for WebGL to solve the problem, since there will be no reflows.

@jonathanolson
Copy link
Contributor Author

Also, liberal use of Canvas for things that don't need to be redrawn often may also help improve this.

@samreid
Copy link
Member

samreid commented Sep 12, 2014

Is there an easy way to get a DAG size from scenery? If that is an important performance measure, perhaps we should have a straightforward API to get it?

@samreid
Copy link
Member

samreid commented Sep 12, 2014

One way to see the DAG (as a tree?) is by using simScene.popupDebug() in the console.

@samreid
Copy link
Member

samreid commented Sep 12, 2014

Perhaps counting the lines in simScene.popupDebug() is a good way to "weigh" the scene graph.

I see the following counts:

1305 lines in the original version.
580 lines when using 'setChildren' instead of 'setVisible'
546 lines when using 'setChildren' and no gridnode
538 lines when using 'setChildren' and no gaugenode ticks
532 lines when using 'setChildren' and no ToggleNodeDeprecated.
456 lines when using all changes above

@samreid
Copy link
Member

samreid commented Sep 12, 2014

@jonathanolson any suggestion how to directly & automatically measure the dom reflow time using code? Or is the chrome developer tool the best way to do this?

@jonathanolson
Copy link
Contributor Author

I just made a recursive function to count in the console, but I don't mind adding a function to Node to count.

@jonathanolson
Copy link
Contributor Author

I don't know of any way besides checking in the dev tools to actually view it, I'd just qualitatively test performance.

@pixelzoom
Copy link
Contributor

This should be reported to the Chrome team.

@samreid
Copy link
Member

samreid commented Sep 24, 2014

I tested removing all of the svg elements from the otherwise webgl-rendered ESPB and the problem went away. So perhaps rendering things in WebGL could solve this problem.

@samreid
Copy link
Member

samreid commented Oct 8, 2014

Chrome 38 came out today, and this problem just got a whole lot worse. 😞

@samreid
Copy link
Member

samreid commented Oct 14, 2014

This issue seems to go away if I get rid of everything except for the WebGL canvas (But I have to get rid of the navbar too). This suggests that going to WebGL could solve this problem, but we would have to use WebGL for the navbar as well as the sim screen.

@jonathanolson
Copy link
Contributor Author

Please see tests/browsers/chrome-cursor-test.html. Reproduces the slowdown with just a static SVG state.

@pixelzoom
Copy link
Contributor

@jbphet says: tested this in Arithmetic recently, and it may be worse with scenery 0.2.

@jonathanolson
Copy link
Contributor Author

Timeline of FPAF shows that the cursor update triggers recalculation of styles (more expensive) and layout (less expensive). Compositing looks like a significant (dominating?) factor unless I'm reading the plot wrong (I'll read up on the tools a bit):

fpaf-composite

We could consider some creative (hacky) ways of not triggering style recalculation but still changing the cursor (e.g. maybe creating divs for each cursor type and change their stacking order might work).

Will probably need to bring back the original cursor toggling test page.

@jonathanolson
Copy link
Contributor Author

#337 should help with this.

@jonathanolson
Copy link
Contributor Author

Unable to reproduce the cursor issue on Chrome 45 (Win 7), anyone else (@pixelzoom, @samreid, @jbphet, @aaronsamuel137) noticed this in sims recently?

@aaronsamuel137
Copy link
Contributor

I can't seem to reproduce it either. I remember a slight stutter in color-vision when the cursor changed and the photon view was present. Doesn't seem to happen anymore.

@pixelzoom
Copy link
Contributor

I have never seen this issue.

@jonathanolson
Copy link
Contributor Author

Can't reproduce on other platforms. Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants