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

refactor: Tweak generated Dispose(bool) to make #8688 less common #8854

Merged
merged 1 commit into from
May 24, 2022

Conversation

spouliot
Copy link
Contributor

  • avoid generating disabled Dispose code for Android
  • inline RequestCollect method (if only to reduce metadata)
  • reuse the Count check to avoid the enumerator (iOS)
  • use the macOS r/w Subviews property to avoid multiple native calls

GitHub Issue (If applicable): closes #

PR Type

What kind of change does this PR introduce?

Refactoring (no functional changes, no api changes)

What is the current behavior?

Applications can display warnings like Tried to create a managed reference from an object that already has a managed reference, see #8688

What is the new behavior?

This warning should not be seen, on macOS, with the changes included in the PR as it avoid the RemoveFromSuperview call, inside with Xamarin.Mac would call Superview and expose a bug inside the Xamarin runtime leading to the warning.

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

This first PR set the stage to fix #8688 [1] (in a subsequent PR). This
is splitted into a few PRs so Uno's local fix can be removed once the
issue is fixed inside Xamarin SDKs.

This also includes a workaround (for macOS only) to the Xamarin
runtime resurfacing bug [2] - because Xamarin.Mac's RemoveFromSubviews
has custom code that calls the Superview method.

[1] #8688
[2] xamarin/xamarin-macios#15089

Internal Issue (If applicable):

…ss common

- avoid generating disable `Dispose` code for Android
- inline `RequestCollect` method (if only to reduce metadata)
- reuse the `Count` check to avoid the enumerator (iOS)
- use the macOS r/w `Subviews` property to avoid multiple native calls
@spouliot spouliot requested a review from a team May 23, 2022 01:25
@gitpod-io
Copy link

gitpod-io bot commented May 23, 2022

@workgroupengineering
Copy link
Contributor

perhaps it is better to add a comment with reference at the issue.

@spouliot
Copy link
Contributor Author

@workgroupengineering

perhaps it is better to add a comment with reference at the issue.

Both (Uno and Xamarin) issues are in the PR comments, but you likely mean in the source code, right ?

If so that will be part of the 2nd PR - which is meant to be reverted once the Xamarin runtime bug is fixed. The changes inside this (1st) PR should remain even after the fix 😄

@workgroupengineering
Copy link
Contributor

I think it is always better to add a comment in the code when the changes are not obvious to avoid regressions.

From the tests I have made, this PR also fix issue #8682

@jeromelaban
Copy link
Member

Nice improvement, indeed! This will avoid doing too much work on tree leaves. Thanks!

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.

[iOS][net6] Tried to create a managed reference from an object that already has a managed reference
4 participants