Skip to content

Performance issues when setting the "active" pseudoclass #293

Closed
@MatthiasJFM

Description

I've noticed that on my application there is a massive performance impact when setting the "active" pseudoclass in Element::ProcessDefaultAction(Event& event).
More specifically setting the class and removing it again triggers a cascade of update calls through the DOM tree, calling through:
Element::Update()
Element::UpdateProperties()
ElementStyle::UpdateDefinition()
StyleSheet::GetElementDefiniton()
StyleSheetNode::IsApplicable()
...where it checks the classnames and pseudoclassnames.
For a little more context I am using the lib on a mobile device, so this is happening in response to touch events - repeatedly tapping the screen drives CPU usage up to 50-60%. Not setting the pseudoclass brings CPU usage down to 8%. I think to repro this you would need to click pretty wildly, but worth having a look into!

Afaict this is being caused by a massive number of calls into IsClassSet() (not so much IsPseudoClassSet() but I guess that's because they appear less in my StyleSheetNodes) when it runs through all the StyleSheetNodes multiple times in an update call.

Metadata

Assignees

No one assigned

    Labels

    performancePerformance suggestions or specific issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions