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

Bring back some aspect of ConvertView on TableView and avoid AT_MOST Measure #20130

Merged
merged 6 commits into from Feb 7, 2024

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented Jan 24, 2024

Description of Change

We started hitting an issue on our legacy tests where the EntryCell started causing the ContentPage to get recycled. AFAICT this was caused by our changes here #19723. That PR disables recycling but we still return the same platformView using our handler recycling. That change was causing OnAttachedToWindow to fire twice which appeared to put the EditText field into a state where it would leak.

Disabling ConvertView but returning a previously return view appears to cause ListView to behave in unexpected way. The comment here expands on the platform reasons specifically. It basically comes down to Androids expectation when it calls "getView", if the convertView is null then it needs to return a completely new view that's never been used before, if the convertView isn't null then you're expected to use that view. If you violate that pattern then the state of internal affairs gets out of line.

The main fix, I would say, are the changes to converting AT_MOST to EXACT. The way we do view recycling is just completely incompatible with how AT_MOST works. Ideally we could make AT_MOST work but we would need to figure out how to juggle between the random scrap views Android creates vs the actual views attached to the window.

Issues Fixed

Fixes #5924

@PureWeen PureWeen changed the base branch from main to release/8.0.1xx-sr2 February 5, 2024 21:30
@PureWeen PureWeen marked this pull request as ready for review February 5, 2024 21:31
@PureWeen PureWeen requested a review from a team as a code owner February 5, 2024 21:31
@PureWeen PureWeen requested review from jfversluis and rmarinho and removed request for a team February 5, 2024 21:31
@PureWeen PureWeen changed the title Don't remeasure TableView if specs are the same Bring back some aspect of ConvertView on TableView and avoid AT_MOST Measure Feb 5, 2024
@PureWeen
Copy link
Member Author

PureWeen commented Feb 6, 2024

iOS Failures are unrelated

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

Looking good, just some questions on things.

@@ -107,7 +137,10 @@ public override SizeRequest GetDesiredSize(double widthConstraint, double height
continue;
}

AView listItem = _adapter.GetView(i, null, Control);
var platformView = cell.Handler?.PlatformView as AView;
Copy link
Member

Choose a reason for hiding this comment

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

Should this be ToPlatform()? If we don't want to create, will it break if it is using a wrapper/container view? Or is that not possible with these views

Copy link
Member Author

@PureWeen PureWeen Feb 7, 2024

Choose a reason for hiding this comment

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

yea, not really possible with cells. Also, toPlatform doesn't really work here because we only want to return a PlatformView if it's already been created. This is just to fake the ConvertView behavior if the platformview already exists. Also, the cells only implement IElementHandler so they don't have a container view

var platformView = cell.Handler?.PlatformView as AView;
var convertView = (platformView?.Parent as AView) ?? platformView;

AView listItem = _adapter.GetView(i, convertView, Control);
int widthSpec;

Copy link
Member

Choose a reason for hiding this comment

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

A few lines down, I see an atmost... Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, but, it's been like that since net6 so I'm hesitant to change it without a use case at this point

ViewCellContainer c = view.PlatformView.GetParentOfType<ViewCellContainer>();
// If the convertView is null we don't want to return the same view, we need to return a new one.
// We should probably do this for ListView as well
if (ParentView is TableView)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we create an issue linking to this comment to remember to review the same changes with the ListView?

@PureWeen
Copy link
Member Author

PureWeen commented Feb 7, 2024

Android UITest failure unrelated - HideSoftInputOnTappedPageTest
Bugzilla60123 failure unrelated

@PureWeen PureWeen merged commit 08d0388 into release/8.0.1xx-sr2 Feb 7, 2024
35 of 41 checks passed
@PureWeen PureWeen deleted the fix_tv_leak branch February 7, 2024 23:59
@github-actions github-actions bot locked and limited conversation to collaborators Mar 9, 2024
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