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

[net8.0] Fix cells leak tests #16231

Merged
merged 2 commits into from Jul 20, 2023
Merged

[net8.0] Fix cells leak tests #16231

merged 2 commits into from Jul 20, 2023

Conversation

rmarinho
Copy link
Member

Description of Change

Try get a green build for net8.0

}
}
//[Fact("Cells Do Not Leak")]
//public async Task CellsDoNotLeak()
Copy link
Contributor

Choose a reason for hiding this comment

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

Better use just Skip with a comment (the comment will help to understand the status). Also, should we create a related issue where @jonathanpeppers could work?

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

Let's fix this test. Can you share cases where it failed?

It's already caught a new leak that was introduced in: #15856

@rmarinho
Copy link
Member Author

@jonathanpeppers first time it started was with Android bump commit 310d5d4 doesn't make much sense

@jonathanpeppers
Copy link
Member

Let's try this: #16237

And then it's possible there is something that is going wrong in .NET 8? If this still fails.

I've found the most reliable way to make DeviceTests
run the GC for all platforms is:

    Assert.NotNull(pageReference);
    await AssertionExtensions.Wait(() =>
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();
        return !pageReference.IsAlive;
    }, timeout: 5000);

Let's standardize on this, so we can instead do:

    await AssertionExtensions.WaitForGC(pageReference);

And if you have multiple:

    await AssertionExtensions.WaitForGC(pageReference, handlerReference);

The helper method also checks if the `params WeakReference[]` is empty,
or any `WeakReference` are null. I simplified various tests with this
change.

# Conflicts:
#	src/Controls/tests/DeviceTests/Elements/CollectionView/CollectionViewTests.iOS.cs
@rmarinho rmarinho changed the title [net8.0] Ignore cells leak [net8.0] Fix cells leak tests Jul 20, 2023
@rmarinho rmarinho removed the do-not-merge Don't merge this PR label Jul 20, 2023
@rmarinho rmarinho enabled auto-merge (squash) July 20, 2023 11:05
@rmarinho rmarinho dismissed jonathanpeppers’s stale review July 20, 2023 11:06

Commit from Peppers is used

@rmarinho rmarinho merged commit 46a34fc into net8.0 Jul 20, 2023
32 checks passed
@rmarinho rmarinho deleted the ignore-cells-leak branch July 20, 2023 11:06
GC.Collect();
GC.WaitForPendingFinalizers();

await AssertionExtensions.WaitForGC(labels.ToArray());
Copy link
Member

Choose a reason for hiding this comment

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

Ok awesome! Glad this fixed it.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants