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

Merge main into net9.0 #24341

Merged
merged 16 commits into from
Aug 21, 2024
Merged

Merge main into net9.0 #24341

merged 16 commits into from
Aug 21, 2024

Conversation

mattleibow
Copy link
Member

Description of Change

Update the net9.0 branch with all the latest things.

mattleibow and others added 14 commits August 15, 2024 15:41
* Fix cake scripts to work locally

* - fix for windows

* - cleanup device retrieval

* - fix processSettings.RedirectedStandardOutputHandler

* Add build tasks
Context: #23991
Context: https://github.com/chabiss/periodictable

In the above sample, a lot of time is spent in:

    921.46ms (4.3%) mono!Android.Graphics.Paint.Cap.get_Butt()
    872.40ms (4.1%) mono!Android.Graphics.Paint.Join.get_Miter()

This exposes a performance issue with `Java.Lang.Enum` values:

* `java.lang.Enum` in Java are objects (not `int` like C#)

* When accessing an enum value, Java returns an object we have to wrap
  in a C# object.

* .NET for Android has to do bookkeeping around this, lookup in a hash
  table, etc.

To avoid this, we can store the `Join` and `Cap` values in a static
field and avoid calling into Java. This approach is already working
in .NET MAUI for `ImageView.ScaleType`:

https://github.com/dotnet/maui/blob/9361f90a5d9eaf922432b36906ff18f6ccb2f52f/src/Core/src/Platform/Android/AspectExtensions.cs#L7-L10

After this change, the time spent is completely gone:

    2.41ms (0.02%) mono.android!Android.Graphics.Paint.Join.get_Miter()

I can't find the same call for (the unfortunately named) `get_Butt()`
at all.

In the future, we might consider changing the C# binding for
`Java.Lang.Enum` to "auto-cache" values in C# static fields. Not sure
if there is enough time left for it to happen in .NET 9, though.
Context: #23991
Context: https://github.com/chabiss/periodictable

In the above sample in `Debug`-mode, a lot of time is spent in:

    1.20s (3.3%) microsoft.maui!Microsoft.Maui.Platform.StrokeExtensions.UpdateBorderStroke(Android.Views.View,Microsoft.Maui.IBorderStroke)
    0.42s (1.2%) microsoft.maui!Microsoft.Maui.Platform.StrokeExtensions.UpdateMauiDrawable(Android.Views.View,Microsoft.Maui.IBorderStroke)

If you drill-in, a lot of the time is spent in, `View.Background`,
which is called a lot overall as well:

    627.20ms (1.7%) mono.android!Android.Views.View.get_Background()

Reviewing `StrokeExtensions`, it does call `View.Background` over and
over, many times.

To fix this:

* Call `View.Background` once and store it in a `MauiDrawable?` local
  variable.

* Subsequent calls to methods in `StrokeExtensions` pass the local
  variable along.

`View.Background` is now called many fewer times and the result is:

    1.07s (2.90%) microsoft.maui!Microsoft.Maui.Platform.StrokeExtensions.UpdateBorderStroke(Android.Views.View,Microsoft.Maui.IBorderStroke)
    0.34s (0.94%) microsoft.maui!Microsoft.Maui.Platform.StrokeExtensions.UpdateMauiDrawable(Android.Views.View,Microsoft.Maui.IBorderStroke,Microsoft.Maui.Graphics.MauiDrawable&)
    0.33s (0.91%) mono.android!Android.Views.View.get_Background()

This should improve the performance of controls that use
`MauiDrawable` like `<Border/>` on Android.

For the future, we're looking into other ways to improve Debug-mode
performance at:

* dotnet/runtime#106491
* Fix 17865

* Added device test

* Updated test

* Fixup use of event

* Update MauiProgram.cs

* Fix UI test

---------

Co-authored-by: Mike Corsaro <[email protected]>
Co-authored-by: Mike Corsaro <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>
…xception - fix (#21714)

* [Android] Added null checks (#21437)

* Updated test

* Updated test

* Update Issue21513.cs

---------

Co-authored-by: Javier Suárez <[email protected]>
* Optimize WrapperView

* CS

* Bugfix

* Bugfix (2)

* Remove SuppressFinalize
@mattleibow mattleibow requested review from a team as code owners August 20, 2024 20:43
@mattleibow mattleibow changed the base branch from main to net9.0 August 20, 2024 20:43
@mattleibow mattleibow requested review from rmarinho and PureWeen and removed request for a team, rmarinho and jsuarezruiz August 20, 2024 20:43
PureWeen
PureWeen previously approved these changes Aug 20, 2024
@rmarinho
Copy link
Member

D:\a\_work\1\s\src\Controls\src\Core\Element\Element.cs(787,84): error CS7036: There is no argument given that corresponds to the required parameter 'comparisonType' of 'MemoryExtensions.CompareTo(ReadOnlySpan<char>, ReadOnlySpan<char>, StringComparison)' [D:\a\_work\1\s\src\Controls\src\Core\Controls.Core.csproj::TargetFramework=net8.0-tizen7.0]

# Conflicts:
#	eng/pipelines/common/ui-tests-build-sample.yml
#	src/Core/src/Core.csproj
@mattleibow mattleibow merged commit 11aa1bd into net9.0 Aug 21, 2024
117 checks passed
@mattleibow mattleibow deleted the merge-main-net9 branch August 21, 2024 22:12
@samhouts samhouts added the fixed-in-net9.0-nightly This may be available in a nightly release! label Aug 27, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
fixed-in-net9.0-nightly This may be available in a nightly release!
Projects
None yet
Development

Successfully merging this pull request may close these issues.