Skip to content

Improve huge selection handling#1399

Merged
saskliutas merged 5 commits into
masterfrom
property-grid-unified-selection
Jun 15, 2026
Merged

Improve huge selection handling#1399
saskliutas merged 5 commits into
masterfrom
property-grid-unified-selection

Conversation

@saskliutas

Copy link
Copy Markdown
Member

Closes #1398

Updated usePropertyDataProviderWithUnifiedSelection to avoid loading instance keys when selection is huge and exceeds limit.
Updated Selectables.load to avoid freezing main thread when loading huge selection.

@saskliutas saskliutas requested a review from a team as a code owner June 12, 2026 14:18
Copilot AI review requested due to automatic review settings June 12, 2026 14:18
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 767980a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@itwin/presentation-components Patch
@itwin/unified-selection Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unified selection benchmark

Benchmark suite Current: 767980a Previous: 701b08c Deviation Status
compute selection for 50k elements 386 ms 401 ms -3.74% 〰️
compute selection for 50k elements (P95 of main thread blocks) 31 ms 32 ms -3.13% 〰️
compute parent selection for 50k elements 345 ms 357 ms -3.36% 〰️
compute parent selection for 50k elements (P95 of main thread blocks) 31 ms 35 ms -11.43% 〰️
compute top ancestor selection for 50k elements 559 ms 561 ms -0.36% 〰️
compute top ancestor selection for 50k elements (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
compute category selection for 50k elements 101 ms 104 ms -2.88% 〰️
compute category selection for 50k elements (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
compute model selection for 50k elements 85 ms 84 ms 1.19% 〰️
compute model selection for 50k elements (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
compute functional selection for 50k 3D elements 427 ms 443 ms -3.61% 〰️
compute functional selection for 50k 3D elements (P95 of main thread blocks) 34 ms 31 ms 9.68% 〰️
compute parent functional selection for 50k 3D elements 443 ms 464 ms -4.53% 〰️
compute parent functional selection for 50k 3D elements (P95 of main thread blocks) 35 ms 35 ms 0% 🟰
compute top ancestor functional selection for 50k 3D elements 1173 ms 1191 ms -1.51% 〰️
compute top ancestor functional selection for 50k 3D elements (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
compute functional selection for 50k 2D elements 2988 ms 3037 ms -1.61% 〰️
compute functional selection for 50k 2D elements (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
compute parent functional selection for 50k 2D elements 2983 ms 2933 ms 1.70% 〰️
compute parent functional selection for 50k 2D elements (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
compute top ancestor functional selection for 50k 2D elements 3047 ms 3072 ms -0.81% 〰️
compute top ancestor functional selection for 50k 2D elements (P95 of main thread blocks) 0 ms 0 ms 0% 🟰
hilite 50k elements 1266 ms 1192 ms 6.21% 〰️
hilite 50k elements (P95 of main thread blocks) 55 ms 52 ms 5.77% 〰️
hilite 50k group elements 240 ms 236 ms 1.69% 〰️
hilite 50k group elements (P95 of main thread blocks) 31 ms 31 ms 0% 🟰
hilite 1k subjects 46999 ms 48341 ms -2.78% 〰️
hilite 1k subjects (P95 of main thread blocks) 26 ms 28 ms -7.14% 〰️
hilite 50k subcategories 310 ms 315 ms -1.59% 〰️
hilite 50k subcategories (P95 of main thread blocks) 39 ms 39 ms 0% 🟰
hilite 50k functional 3D elements 31446 ms 29150 ms 7.88% 〰️
hilite 50k functional 3D elements (P95 of main thread blocks) 41 ms 41 ms 0% 🟰
hilite 50k functional 2D elements 6678 ms 6329 ms 5.51% 〰️
hilite 50k functional 2D elements (P95 of main thread blocks) 43 ms 41 ms 4.88% 〰️

This comment was automatically generated by workflow using github-action-benchmark.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses performance issues when unified selection contains a very large number of elements by avoiding unnecessary instance-key materialization and by yielding during large instance-key loads to reduce main-thread blocking.

Changes:

  • Updated usePropertyDataProviderWithUnifiedSelection to short-circuit selection handling when selection size exceeds the configured limit (avoid creating/loading a full KeySet).
  • Updated Selectables.load to periodically yield while iterating large instance-key sets to reduce UI freezing.
  • Added changesets for @itwin/unified-selection and @itwin/presentation-components.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/unified-selection/src/unified-selection/Selectable.ts Adds main-thread yielding while iterating large instanceKeys selections during Selectables.load.
packages/components/src/presentation-components/propertygrid/UseUnifiedSelection.tsx Avoids materializing KeySet from storage when selection is over limit; propagates either KeySet or size.
.changeset/hip-spoons-tease.md Changeset for @itwin/unified-selection performance improvement.
.changeset/common-frogs-dig.md Changeset for @itwin/presentation-components selection-limit optimization.

@saskliutas saskliutas merged commit 9f2f1f4 into master Jun 15, 2026
18 checks passed
@saskliutas saskliutas deleted the property-grid-unified-selection branch June 15, 2026 06:50
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

Successfully merging this pull request may close these issues.

Poor PropertyGridComponent performance selecting large number of elements at once

3 participants