Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve UIA Provider Cleanup Logic for Virtual ListView Items#13953

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
LeafShi1 wants to merge3 commits intodotnet:main
base:main
Choose a base branch
Loading
fromLeafShi1:Fix_13922_Remove_IsAccessibilityObjectCreated-_from_ListViewItem

Conversation

@LeafShi1
Copy link
Member

@LeafShi1LeafShi1 commentedOct 10, 2025
edited
Loading

Fixes#13922

Root Cause

WhenListView.VirtualMode = true, the current implementation of ReleaseUiaProvider() iterates over all indices (Items.Count) and callsItems.GetItemByIndex().
This triggersOnRetrieveVirtualItem for every index, forcing creation of all virtual items even if they were never displayed or accessed.

Result in:
Severe performance degradation for large virtual lists (e.g., tens of thousands of items).
High memory pressure due to unnecessary ListViewItem instantiation.
UI freeze during control disposal.

Proposed changes

This PR improves the cleanup logic for UI Automation (UIA) providers in ListView when operating inVirtualMode = true. Specifically:

  • Introduces a_uiaAccessedIndices tracking mechanism to record only the indices of items whoseAccessibilityObject was created by UIA.
  • UpdatesReleaseUiaProvider to selectively release UIA providers only for accessed items, avoiding full traversal ofVirtualListSize and improving performance.
  • EnsuresNotifyUiaCreated is called duringAccessibilityObject creation to maintain accurate tracking.
  • Prevents triggeringRetrieveVirtualItem during cleanup, which previously caused unnecessary item creation and severe performance degradation in large virtual lists.

Customer Impact

  • Improves performance and responsiveness when using ListView in virtual mode with large datasets

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

When closing the form containing the ListView (in virtual mode), followed by closing the main form, the application experienced a noticeable delay.

BeforeChanges.mp4

After

When closing the form containing the ListView (in virtual mode), and subsequently closing the main form, the main form closes immediately with no noticeable delay.

AfterChanges.mp4

Test methodology

  • Manually

Test environment(s)

  • .net 10.0.0-rc.1.25507.102
Microsoft Reviewers:Open in CodeFlow

@github-actionsgithub-actionsbot added the area-DarkModeIssues relating to Dark Mode feature labelOct 10, 2025
@dotnet-policy-servicedotnet-policy-servicebot added the draftdraft PR labelOct 10, 2025
@LeafShi1LeafShi1force-pushed theFix_13922_Remove_IsAccessibilityObjectCreated-_from_ListViewItem branch frome987626 todaf7e8dCompareOctober 11, 2025 09:21
@LeafShi1LeafShi1force-pushed theFix_13922_Remove_IsAccessibilityObjectCreated-_from_ListViewItem branch fromdaf7e8d toc0e5c79CompareOctober 11, 2025 09:57
@LeafShi1LeafShi1 changed the titleAdjust the judgment of IsAccessibilityObjectCreated in the ReleaseUiaProvider method of ListView and ListViewItemImprove UIA Provider Cleanup Logic for Virtual ListView ItemsOct 11, 2025
@codecov
Copy link

codecovbot commentedOct 11, 2025
edited
Loading

Codecov Report

❌ Patch coverage is96.42857% with1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.15120%. Comparing base (e36dddd) to head (c0e5c79).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@##                main      #13953         +/-   ##===================================================+ Coverage   77.15093%   77.15120%   +0.00027%===================================================  Files           3276        3276                   Lines         645116      645141         +25       Branches       47705       47709          +4     ===================================================+ Hits          497713      497734         +21+ Misses        143716      143712          -4- Partials        3687        3695          +8
FlagCoverage Δ
Debug77.15120% <96.42857%> (+0.00027%)⬆️
integration18.99715% <35.71429%> (+0.00740%)⬆️
production52.01777% <96.42857%> (+0.00417%)⬆️
test97.40835% <ø> (-0.00113%)⬇️
unit49.47502% <96.42857%> (+0.01445%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Olina-ZhangOlina-Zhang removed the area-DarkModeIssues relating to Dark Mode feature labelOct 13, 2025
@LeafShi1LeafShi1 marked this pull request as ready for reviewOctober 13, 2025 08:45
@LeafShi1LeafShi1 requested a review froma team as acode ownerOctober 13, 2025 08:45
@dotnet-policy-servicedotnet-policy-servicebot removed the draftdraft PR labelOct 13, 2025
Copy link
Member

@KlausLoeffelmannKlausLoeffelmann left a comment

Choose a reason for hiding this comment

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

I think, with this approach, we are "unvirtualize" ListView items and prevent them from being GC-collected. Let's discuss this and make sure, I am not missing anything.

LeafShi1 reacted with thumbs up emoji
@dotnet-policy-servicedotnet-policy-servicebot added the waiting-author-feedbackThe team requires more information from the author labelOct 15, 2025
@dotnet-policy-servicedotnet-policy-servicebot removed the waiting-author-feedbackThe team requires more information from the author labelOct 17, 2025
@LeafShi1
Copy link
MemberAuthor

with this approach, we are "unvirtualize" ListView items and prevent them from being GC-collected

@KlausLoeffelmann I updated the PR, please review it again. Added _uiaAccessedIndices to track only the indices accessed by UIA in virtual mode, _uiaAccessedIndices stores only integer indices, not ListViewItem objects. Since there is no strong reference to the actual items, the GC can still reclaim them when they are no longer used.

for(inti=0;i<Items.Count;i++)
if(VirtualMode)
{
foreach(intindexin_uiaAccessedIndices)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

In virtual mode, ListViewItem objects aren't real objects; instead, they're dynamically generated using the RetrieveVirtualItem method.

If the data source changes (such as insertions, deletions, or sorting), the original index may no longer correspond to the original item.

@LeafShi1LeafShi1 marked this pull request as draftOctober 23, 2025 06:26
@dotnet-policy-servicedotnet-policy-servicebot added the draftdraft PR labelOct 23, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@KlausLoeffelmannKlausLoeffelmannKlausLoeffelmann requested changes

@JeremyKuhneJeremyKuhneAwaiting requested review from JeremyKuhne

Requested changes must be addressed to merge this pull request.

Assignees

@LeafShi1LeafShi1

Labels

draftdraft PR

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

UiaProvider implementation forces virtual ListView to retrieve ALL ListViewItems at WM_DESTROY

3 participants

@LeafShi1@KlausLoeffelmann@Olina-Zhang

[8]ページ先頭

©2009-2025 Movatter.jp