Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@albyrock87
Copy link
Contributor

@albyrock87 albyrock87 commented Sep 11, 2025

Description of Change

Backgrounds are everywhere in our apps, so we must be fast when drawing android views, and Java -> C# is not.

This PR tries to do its best to completely move the logic into a java PlatformDrawable class.

Benchmarks (~50% improvements in mapping, ~60% improvement in rendering time)

I used #24414 as main page wrapped into a Shell component given it has a drawChild method which shows the cumulative draw time.

The results are impressive and will for sure make an impact!

24414-net10.json
image
image
image

24414-pr-final2.json
image
image
image

@dotnet-policy-service dotnet-policy-service bot added the community ✨ Community Contribution label Sep 11, 2025
@albyrock87 albyrock87 changed the base branch from main to net10.0 September 11, 2025 09:39
@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@jsuarezruiz jsuarezruiz added area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing perf/general The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) labels Sep 11, 2025
Copy link
Contributor

@jsuarezruiz jsuarezruiz left a comment

Choose a reason for hiding this comment

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

There are some related failing tests:
image

Differences between snapshots. Based on the failing tests, seems like not apply dynamic changes (like a dynamic binding for example. Could you review it? Let me know if can help with something.

@albyrock87 albyrock87 force-pushed the android-drawable-perf branch 4 times, most recently from a042aaa to 10fd93f Compare September 11, 2025 20:08
@albyrock87
Copy link
Contributor Author

@jsuarezruiz you can run AZP again.. though initially I had 80% perf improvement, but now with the last force push it's like 0%.. anyway I'm curious about UI tests failures.

So I must have done something wrong, or I must have missed some caching opportunity.
I'll try to look at this again tomorrow.

@albyrock87 albyrock87 force-pushed the android-drawable-perf branch from 10fd93f to 5f10e1a Compare September 12, 2025 07:33
@albyrock87
Copy link
Contributor Author

albyrock87 commented Sep 12, 2025

@jsuarezruiz I've pushed another commit, and this time the timing looks better but not what I wanted/expected.

There's only a 3ms performance gain.. now maybe this becomes much higher with a real world complex app, but I hoped to achieve something more.

Please run /azp

@albyrock87
Copy link
Contributor Author

Wait, I found another issue.

@albyrock87 albyrock87 force-pushed the android-drawable-perf branch 2 times, most recently from fee1cbf to 6a5f850 Compare September 12, 2025 10:27
@albyrock87
Copy link
Contributor Author

@jsuarezruiz this is now ready, I've updated all the benchmarks in the description

@albyrock87 albyrock87 marked this pull request as ready for review September 12, 2025 10:43
@albyrock87 albyrock87 requested a review from a team as a code owner September 12, 2025 10:43
@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@albyrock87
Copy link
Contributor Author

albyrock87 commented Sep 13, 2025

@jsuarezruiz @PureWeen the PR is now ready, I added a few commits with the fixes and updated screenshots, here's a summary:

  • IShape can change even without changing instance (because Shape is a bindable property) so for performance reasons, I've introduced an internal IVersionedShape so that the MauiDrawable can still avoid some calls and retain the expected performance
  • Screenshots are different because I finally fixed the bug where the default stroke color was black on Android (you can verify other platforms and you will see the border is transparent unless the developer specifies a color)
  • Fixed gradients not working

@mattleibow
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen
Copy link
Member

PureWeen commented Sep 13, 2025

/azp run

@rmarinho
Copy link
Member

@albyrock87 can you rebase?

@albyrock87 albyrock87 force-pushed the android-drawable-perf branch from db3b3a0 to 4bb32c8 Compare September 26, 2025 07:50
@albyrock87
Copy link
Contributor Author

@rmarinho I've rebased the PR onto the last net10.0 commit

@PureWeen
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@albyrock87
Copy link
Contributor Author

albyrock87 commented Sep 29, 2025

There are some broken UITests on CI so I tested them all locally and they pass:

  • VerifyFlyoutPage_IsGestureEnabled
  • Issue29558InputViewShouldNotHideOnUnfocusCall
  • HeaderFooterHorizontalViewWorks
  • VerifyClickAroundOverflowMenuItem
  • CookiesCorrectlyLoadWithMultipleWebViews
  • ProgressSpinnerWorksWhenReEnabled

All 1019 DeviceTests passed locally.

@PureWeen PureWeen modified the milestones: .NET 10.0-rc2, .NET 10 SR1 Oct 6, 2025
@bcaceiro
Copy link

Any news on this?

@bcaceiro
Copy link

Tested in debug mode - everything ok!

@albyrock87 albyrock87 force-pushed the android-drawable-perf branch from 4bb32c8 to c113d61 Compare October 23, 2025 12:47
@albyrock87
Copy link
Contributor Author

Rebased on top of latest net10.0 commit.

@PureWeen PureWeen modified the milestones: .NET 10 SR1, .NET 10.0 SR2 Nov 4, 2025
@albyrock87 albyrock87 changed the base branch from net10.0 to main November 10, 2025 16:36
# Conflicts:
#	docs/design/UITesting.md
#	src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt
#	src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt
@jfversluis
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@PureWeen PureWeen modified the milestones: .NET 10.0 SR2, .NET 10.0 SR3 Dec 2, 2025
# Conflicts:
#	src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt
#	src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing community ✨ Community Contribution perf/general The issue affects performance (runtime speed, memory usage, startup time, etc.) (sub: perf) platform/android

Projects

Status: Changes Requested

Development

Successfully merging this pull request may close these issues.

8 participants