Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Evict unavailable elements and improve element compare performance #41

Merged
merged 3 commits into from
May 14, 2024

Conversation

aristotelos
Copy link
Collaborator

Evict unavailable elements to prevent COM exceptions and to free memory. See #35. The COM exceptions from a growing set of unavailable elements may be the cause of degrading performance as well.

Add failing test based on reproduce in #35.
@grokys
Copy link
Contributor

grokys commented May 9, 2024

I'm testing this with the hacky repro at https://github.com/grokys/FlaUI.WebDriver/tree/tests/slowdown-demo and it doesn't seem to help much. I'm seeing the KnownElementsByElementReference collection growing steadily even though the windows containing the elements have been closed, so looks like elements aren't getting evicted properly.

@grokys
Copy link
Contributor

grokys commented May 9, 2024

Looks like the ProcessId property is returning a value even when the window containing the element is no longer available, so IsAvailable is returning true.

Evict unavailable elements and windows to prevent COM exceptions and to
free memory. See #35. The COM exceptions from a growing set of
unavailable elements may be the cause of degrading performance as well.
Use the RuntimeId property to speed up equality comparison for known
elements and windows. Along with this, catch possible COM exceptions
during equality comparison if the element is no longer available.

Closes #35.
@aristotelos
Copy link
Collaborator Author

I'm testing this with the hacky repro at https://github.com/grokys/FlaUI.WebDriver/tree/tests/slowdown-demo and it doesn't seem to help much. I'm seeing the KnownElementsByElementReference collection growing steadily even though the windows containing the elements have been closed, so looks like elements aren't getting evicted properly.

I've done a quick performance profile and pushed an update that uses the RuntimeId for a fast initial comparison. I have tested with your manual performance test scenario and it seems to work!

@aristotelos aristotelos changed the title Evict unavailable elements Evict unavailable elements and improve element compare performance May 14, 2024
@aristotelos aristotelos merged commit bbb1fb7 into main May 14, 2024
3 checks passed
@aristotelos aristotelos deleted the evict-unavailable-elements branch May 14, 2024 04:38
@grokys
Copy link
Contributor

grokys commented May 14, 2024

Thanks! This does seem to improve things, but also causes #42 :(

@grokys
Copy link
Contributor

grokys commented May 14, 2024

To give a bit more details on how much this helped:

The Avalonia integration test suite before this PR took over an hour to run. After this PR, it takes less than 4 minutes ;)

(This is without cleanup running, I commented that out due to #42).

@ddeltasolutions
Copy link

ddeltasolutions commented May 14, 2024 via email

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.

COMException in UIA3Automation.Compare and performance problems with long-running sessions.
3 participants