Skip to content

Conversation

LeafShi1
Copy link
Member

@LeafShi1 LeafShi1 commented Oct 10, 2025

Fixes #13922

Root Cause

When ListView.VirtualMode = true, the current implementation of ReleaseUiaProvider() iterates over all indices (Items.Count) and calls Items.GetItemByIndex().
This triggers OnRetrieveVirtualItem 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 in VirtualMode = true. Specifically:

  • Introduces a _uiaCreatedItems tracking mechanism to record which ListViewItem instances have had their AccessibilityObject created.
  • Updates ReleaseUiaProvider to selectively release UIA providers only for items that were actually accessed, avoiding unnecessary calls and improving performance.
  • Ensures that NotifyUiaCreated is called during AccessibilityObject creation to maintain accurate tracking.
  • Prevents triggering RetrieveVirtualItem during cleanup, which could otherwise cause 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-actions github-actions bot added the area-DarkMode Issues relating to Dark Mode feature label Oct 10, 2025
@dotnet-policy-service dotnet-policy-service bot added the draft draft PR label Oct 10, 2025
@LeafShi1 LeafShi1 force-pushed the Fix_13922_Remove_IsAccessibilityObjectCreated-_from_ListViewItem branch from e987626 to daf7e8d Compare October 11, 2025 09:21
@LeafShi1 LeafShi1 force-pushed the Fix_13922_Remove_IsAccessibilityObjectCreated-_from_ListViewItem branch from daf7e8d to c0e5c79 Compare October 11, 2025 09:57
@LeafShi1 LeafShi1 changed the title Adjust the judgment of IsAccessibilityObjectCreated in the ReleaseUiaProvider method of ListView and ListViewItem Improve UIA Provider Cleanup Logic for Virtual ListView Items Oct 11, 2025
Copy link

codecov bot commented Oct 11, 2025

Codecov Report

❌ Patch coverage is 96.42857% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.15120%. Comparing base (e36dddd) to head (c0e5c79).
⚠️ Report is 3 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     
Flag Coverage Δ
Debug 77.15120% <96.42857%> (+0.00027%) ⬆️
integration 18.99715% <35.71429%> (+0.00740%) ⬆️
production 52.01777% <96.42857%> (+0.00417%) ⬆️
test 97.40835% <ø> (-0.00113%) ⬇️
unit 49.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-Zhang Olina-Zhang removed the area-DarkMode Issues relating to Dark Mode feature label Oct 13, 2025
@LeafShi1 LeafShi1 marked this pull request as ready for review October 13, 2025 08:45
@LeafShi1 LeafShi1 requested a review from a team as a code owner October 13, 2025 08:45
@dotnet-policy-service dotnet-policy-service bot removed the draft draft PR label Oct 13, 2025
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.

UiaProvider implementation forces virtual ListView to retrieve ALL ListViewItems at WM_DESTROY

2 participants