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 net8.0 into main #17906

Merged
merged 385 commits into from Oct 12, 2023
Merged

Merge net8.0 into main #17906

merged 385 commits into from Oct 12, 2023

Conversation

PureWeen
Copy link
Member

@PureWeen PureWeen commented Oct 9, 2023

Description of Change

Now that we're on the GA run, we are no longer merging main back to NET8.

The Main branch represents SR1 fixes.

This will also let users more easily test PRs since they will now target net8.

rmarinho and others added 30 commits May 29, 2023 15:44
### Description of Change

Small merges to net8 branch
* fix(bug): Fix `RemainingItemsThresholdReached` on Windows

* Fixed an issue where the `CollectionView.RemainingItemsThresholdReached` event wasn't firing on Windows.
* Added a DeviceTest for the event

* Remove switch statement

* Update src/Controls/src/Core/Handlers/Items/ItemsViewHandler.Windows.cs

Co-authored-by: Rui Marinho <me@ruimarinho.net>

---------

Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
Co-authored-by: Rui Marinho <me@ruimarinho.net>
* initial fix

* Add tests

* round test asserts for android

* add conditional for no wrap and add more tests

* Adjust tests for android

* do not run on windows for now

* Add changes to work on Windows

* limit the labels text to the parent container width and adjust tests

* Auto-format source code

* also add a height restriction

* Auto-format source code

---------

Co-authored-by: tj-devel709 <tjlambert@microsoft.com>
Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
Context: #12130
Context: https://github.com/angelru/CvSlowJittering

Profiling a .NET MAUI customer sample while scrolling on a Pixel 5, I
see some interesting time being spent in:

    (0.76%) microsoft.maui!Microsoft.Maui.Graphics.MauiDrawable.OnDraw(Android.Graphics.Drawables.Shapes.Shape,Android.Graphics.Canv
    (0.54%) microsoft.maui!Microsoft.Maui.Graphics.MauiDrawable.SetDefaultBackgroundColor()

This sample has a `<Border/>` inside a `<CollectionView/>` and so you
can see this work happening while scrolling.

Specifically, I found a couple places we had code like:

    _borderPaint.StrokeWidth = _strokeThickness;
    _borderPaint.StrokeJoin = _strokeLineJoin;
    _borderPaint.StrokeCap = _strokeLineCap;
    _borderPaint.StrokeMiter = _strokeMiterLimit * 2;
    if (_borderPathEffect != null)
        _borderPaint.SetPathEffect(_borderPathEffect);

This calls from C# to Java 5 times. Creating a new method in
`PlatformInterop.java` allowed me to reduce it to 1.

I also found:

    void SetDefaultBackgroundColor()
    {
        using (var background = new TypedValue())
        {
            if (_context == null || _context.Theme == null || _context.Resources == null)
                return;

            if (_context.Theme.ResolveAttribute(global::Android.Resource.Attribute.WindowBackground, background, true))
            {
                var resource = _context.Resources.GetResourceTypeName(background.ResourceId);
                var type = resource?.ToLowerInvariant();

                if (type == "color")
                {
                    var color = new AColor(ContextCompat.GetColor(_context, background.ResourceId));
                    _backgroundColor = color;
                }
            }
        }
    }

This is doing a lot of unnecessary stuff: looking up a resource by
name, etc. I found a very simple Java example we could put in
`PlatformInterop.java`:

https://stackoverflow.com/a/14468034

After these changes, I now see:

    (0.28%) microsoft.maui!Microsoft.Maui.Graphics.MauiDrawable.OnDraw(Android.Graphics.Drawables.Shapes.Shape,Android.Graphics.Canv
    (0.04%) microsoft.maui!Microsoft.Maui.Graphics.MauiDrawable.SetDefaultBackgroundColor()

This improves the performance of any `<Border/>` (and other shapes) on
Android, and drops about ~1% of the CPU time while scrolling in this
example.
* Fix Android CollectionView EmptyView

* Update src/Controls/src/Core/Handlers/Items/ItemsViewHandler.Android.cs

Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>

* Fixed build errors

* Auto-format source code

---------

Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>
Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
Context: #12130
Context: https://github.com/angelru/CvSlowJittering
Context: https://github.com/jonathanpeppers/lols

Testing a customer sample and my LOLs per second sample, I could see a
lot of time (5.1%) spent in `PrepareForTextViewArrange()`:

    1.01s (5.1%) microsoft.maui!Microsoft.Maui.ViewHandlerExtensions.PrepareForTextViewArrange(Microsoft.Maui.IViewHandler,Microsoft.Maui
    635.99ms (3.2%) mono.android!Android.Views.View.get_Context()

Most of the time is spent just calling `View.Context` to be able to do:

    internal static int MakeMeasureSpecExact(this Context context, double size)
    {
        // Convert to a native size to create the spec for measuring
        var deviceSize = (int)context!.ToPixels(size);
        return MeasureSpecMode.Exactly.MakeMeasureSpec(deviceSize);
    }

In eea91d3, I added an overload for `ToPixels()` that allows you to
get the same value with an `Android.Views.View` -- avoiding the need
to call `View.Context`.

So we can instead do:

    internal static int MakeMeasureSpecExact(this PlatformView view, double size)
    {
        // Convert to a native size to create the spec for measuring
        var deviceSize = (int)view.ToPixels(size);
        return MeasureSpecMode.Exactly.MakeMeasureSpec(deviceSize);
    }

After these changes, it seems to be ~2.7% better:

    420.68ms (2.4%) microsoft.maui!Microsoft.Maui.ViewHandlerExtensions.PrepareForTextViewArrange(Microsoft.Maui.IViewHandler,Microsoft.Maui

The `View.Context` call is now completely gone.
* Fix Flyout page on iPad

* Update FlyoutPageTests.cs

* - use better override for rotation

* - fix bounds for phone

* - modify ipad flyoutpage to open over content

* - fix click off frame

* - fix a few issues with flyoutpage layout on ipad

* -fix RTL

* - fix pan offset calculations

* - fix width check

* - add bool to allow users to toggle behavior

* Auto-format source code

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
* Remove view from previous containerview

* - fix shell test to correctly add nav bar

* - fix wiring up to modal pages

* - fix extraction of currentpage
* Removed Controls Navigation Controller

This class currently isn't used anywhere so its existence is confusing

* - use mapper methods for platform specifics

* - fix handler registration

* Update ShellTests.cs
…14905)

* Changes updating Android ImageButton Padding

* Updated tests

* Auto-format source code

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
* [CI] Do not rebuild the ms tasks on device tests.

We do not want to rebuild the tasks but use the workloads to run the
device tests. The reasons for this tests are:

1. We should be testing what we ship, not a diff build.
2. We cna emsure that the megapipeline will be testing with the bumped
   android and iOS sdks.

* Allow to rebuild the tasks which is what is expected in the maui repo.

* Use the correct template.
)

Bumps [Microsoft.WindowsAppSDK](https://github.com/microsoft/windowsappsdk) from 1.3.230331000 to 1.3.230502000.
- [Release notes](https://github.com/microsoft/windowsappsdk/releases)
- [Commits](https://github.com/microsoft/windowsappsdk/commits)

---
updated-dependencies:
- dependency-name: Microsoft.WindowsAppSDK
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Ensure MaximumWidth is used when arranging

If Width is not explicitly set but MaximumWidth is, we should still use that as part of the arranging calculations

* Account for alignment

* Add tests

* Auto-format source code

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
* Set Icon to null and back again, working around Android issue

There seems to be an Android bug where it sometimes doesn't
compute the updated icon position correctly, treating
IconGravityTextEnd as if it were IconGravityTextStart.
Setting the Icon to null and then back again forces the
resetIconDrawable call here
https://github.com/material-components/material-components-android/blob/25b3c2b15c9b9499993d6d4a5fb491ffce04517a/lib/java/com/google/android/material/button/MaterialButton.java#L852-L869
to happen which seems to make things work properly.

Fixes #11755

* Add device test

* Update test so results show in window

* Update to use AttachAndRun, for performance

* Use new base class method to call AttachAndRun

* Remove unneeded InvokeOnMainThreadAsync

* Update to use CreateHandlerAndAddToWindow

* Use Theory to test all 4 icon positions

* Update the logic for Top as well
…onstrained (#13936)

* Adjust flex item position to account for reversal when laying out unconstrained
Fixes #7756

* Add automated tests

* Auto-format source code

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
…12011)

* [Android] Use different view types per item template

Previously we were returning a single view type id for all 'items' in collectionview, which meant if you were using a template selector, and had a variety of returned different DataTemplates, each would share the same recycled item.  When a recycled item is reused for a different template, it causes the view for that template to be recreated to be correct for the template selected.

This change returns a unique item id per DataTemplate.Type, so that recycled items should always have the correct DataTemplate.Type and not need to be recreated with a different view hierarchy.

* [iOS] Distinct Cell reuse id's for different DataTemplates

Like on Android, we were using a single cell reuse identifier for iOS "items" regardless of if they had different DataTemplates.  If you were using a data template selector, and returned different data templates, whenever a recycled cell's data template didn't match the data template it needed to display for the new/recycled context, the whole view tree of that template would be recreated.

This change ensures we have a unique cell reuse id for every different DataTemplate.Type that might be returned by the template selector so that when a cell is recycled it should always be reused for the same Data Template it was created for, and so the view hierarchy won't be recreated.

This does require the DetermineCellReuseId to know the indexpath we're getting it for, so a new method was introduced, internal for NET7, protected for NET8+, and in NET8+ the old method is obsoleted.

* Switch up some xaml controls in the sample

* Expose Id internally to use for android view types

* Cache datatemplates for unique item view types

* Api changes (overrides)

* Improve sample

* Remove api txt change that shouldn't have been added

* Update src/Controls/src/Core/Handlers/Items/Android/Adapters/ItemsViewAdapter.cs

Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>

* Update src/Controls/src/Core/Handlers/Items/Android/Adapters/ItemsViewAdapter.cs

Co-authored-by: Rui Marinho <me@ruimarinho.net>

* Update src/Controls/src/Core/Handlers/Items/Android/Adapters/ItemsViewAdapter.cs

Co-authored-by: Rui Marinho <me@ruimarinho.net>

* Use DataTemplate Id for cellReuseId

* Calculate correct position for carousel adapter

The `CarouselViewAdapter` loops by basically returning a very large value for item count of its adapter/source which means the recyclerview is going to ask for view types with a position value that does not actually exist.

Previously this was ok because we returned only a single item view type ever, however now that we want to return a different type for template selector scenarios where there are potentially multiple template types, we need to override also the `GetItemViewType` and pass in the calculated position in the list properly (as we do in `OnBindViewHolder` here already) since the base `ItemsViewAdapter` class now calls `ItemsSource.GetItem(position)` in its `GetItemViewType()` call.

---------

Co-authored-by: Rui Marinho <me@ruimarinho.net>
Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>
Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
Bumps Microsoft.Web.WebView2 from 1.0.1722.45 to 1.0.1774.30.

---
updated-dependencies:
- dependency-name: Microsoft.Web.WebView2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@mattleibow mattleibow changed the title Merge net8 to main Merge net8.0 into main Oct 11, 2023
@mattleibow mattleibow added this to the .NET 8 SR1 milestone Oct 11, 2023
mattleibow and others added 4 commits October 11, 2023 17:12
* Revert "Add globs back into the NuGet for older workloads (#17090)"

This reverts commit aa2adcd.

* Revert "[workload] Move default item updates to workload sdk (#16990)"

This reverts commit d85704d.
### Description of Change

Move to RTM versions for GA
@rmarinho rmarinho marked this pull request as ready for review October 11, 2023 21:22
@rmarinho rmarinho requested review from a team as code owners October 11, 2023 21:22
rmarinho
rmarinho previously approved these changes Oct 11, 2023
rmarinho
rmarinho previously approved these changes Oct 12, 2023
@mattleibow mattleibow merged commit c8ba478 into main Oct 12, 2023
47 checks passed
@mattleibow mattleibow deleted the merge_net8_to_main branch October 12, 2023 15:58
@mattleibow
Copy link
Member

Thanks all! Heros all round!

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

Successfully merging this pull request may close these issues.

None yet