Skip to content

Viewport: changeCategoryDisplay performance degradation #8964

@saskliutas

Description

@saskliutas

Describe the bug
Updating from 5.0.0 to 5.5.0 we noticed performance degradation of Viewport.changeCategoryDisplay method. It looks like it's coming from #8646 and is present since 5.2.3 version.

To Reproduce
Steps to reproduce the behavior:

  1. Checkout branch https://github.com/iTwin/itwinjs-core/tree/change-category-display-perf-test
  2. Build and run sample core full-stack-test (npm run test:chrome)
    it.only("changeCategoryDisplay", async () => {
  3. changeCategoryDisplay call with 50k categories takes about 1min.
  4. Comment out updateSubCategories call in onViewedCategoriesChanged
    this.updateSubCategories(view.categorySelector.categories, undefined);
  5. Rebuild and run test again.
  6. changeCategoryDisplay call with 50k categories is almost instantaneous.

Expected behavior
changeCategoryDisplay should not take about 1 min to add categories to selector.

Additional context
Looking more into this it looks like updateSubCategories does not take much time but changeCategoryDisplay adds categories one by one to selector and onViewedCategoriesChanged is raised after each addition which results in 50k calls.

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions