Skip to content

[Android] Enable Composite Partial ReadyToRun on Release builds by default#33234

Merged
rmarinho merged 26 commits intonet11.0from
android-r2r
Feb 6, 2026
Merged

[Android] Enable Composite Partial ReadyToRun on Release builds by default#33234
rmarinho merged 26 commits intonet11.0from
android-r2r

Conversation

@davidnguyen-tech
Copy link
Member

@davidnguyen-tech davidnguyen-tech commented Dec 19, 2025

Summary

Closes #33387
Closes #33388

This PR enables Composite Partial ReadyToRun by default for CoreCLR on Android Release builds.

The users can customize the ReadyToRun configuration too:

Property Default Customization
PublishReadyToRun true Set false to Disable R2R entirely
PublishReadyToRunComposite true Set false to Use non-composite R2R (separate native images per assembly)
_MauiPublishReadyToRunPartial true Set false to Use full R2R (AOT-compile all methods, not just profiled)
_MauiUseDefaultReadyToRunPgoFiles true Set false to Exclude MAUI's default MIBC profiles

To include custom MIBC profiles:

<ItemGroup>
    <_ReadyToRunPgoFiles Include=<path-to-custom-profile> />
</ItemGroup>

Progress

  • Restore MIBC profiles for PGO
    • Use Android specific profile once available (using irrelevant profiles now just for local testing)
  • Pack the profiles into Microsoft.Maui.Controls.Build.Tasks.nupkg
  • Setup a Maestro subscription
  • Use the profiles to enable Composite Partial ReadyToRun on Android

@davidnguyen-tech davidnguyen-tech self-assigned this Dec 19, 2025
@davidnguyen-tech davidnguyen-tech changed the title [WIP][Android] Enable ReadyToRun with PGO [WIP][Android] Add restoring optimization data Jan 6, 2026
@davidnguyen-tech davidnguyen-tech deleted the android-r2r branch January 6, 2026 10:53
@davidnguyen-tech davidnguyen-tech restored the android-r2r branch January 6, 2026 10:55
@davidnguyen-tech davidnguyen-tech changed the base branch from main to net11.0 January 6, 2026 12:15
@davidnguyen-tech davidnguyen-tech changed the title [WIP][Android] Add restoring optimization data [WIP][Android] Enable Composite Partial ReadyToRun on Release builds by default Jan 14, 2026
@davidnguyen-tech davidnguyen-tech added platform/android perf/app-size Application Size / Trimming (sub: perf) perf/startup-time Issues relating to startup time (sub: perf) labels Jan 14, 2026
@davidnguyen-tech davidnguyen-tech changed the title [WIP][Android] Enable Composite Partial ReadyToRun on Release builds by default [WIP][Android] Enable Composite Profile-Guided Partial ReadyToRun on Release builds by default Jan 14, 2026
@davidnguyen-tech davidnguyen-tech changed the title [WIP][Android] Enable Composite Profile-Guided Partial ReadyToRun on Release builds by default [WIP][Android] Enable Composite Partial ReadyToRun on Release builds by default Jan 15, 2026
@rmarinho
Copy link
Member

/rebase

@davidnguyen-tech davidnguyen-tech marked this pull request as ready for review January 30, 2026 13:09
Copilot AI review requested due to automatic review settings January 30, 2026 13:09
@simonrozsival simonrozsival changed the title [WIP][Android] Enable Composite Partial ReadyToRun on Release builds by default [Android] Enable Composite Partial ReadyToRun on Release builds by default Jan 30, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables Composite Partial ReadyToRun (R2R) by default for Android CoreCLR Release builds, and adds infrastructure to restore/package MIBC (PGO) profiles into the MAUI build tasks NuGet so those defaults have profiles available.

Changes:

  • Enable PublishReadyToRun + composite R2R and add --partial by default for Android CoreCLR Release builds via Microsoft.Maui.Controls.targets.
  • Add an eng/optimizationData.targets restore step to download/copy .mibc optimization data into $(ArtifactsDir)\mibc.
  • Pack copied .mibc files into Microsoft.Maui.Controls.Build.Tasks (buildTransitive/netstandard2.0/mibc) and add a new dependency version.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/Microsoft.Maui.Controls.targets Turns on composite/partial R2R and wires default _ReadyToRunPgoFiles to packaged .mibc profiles for Android CoreCLR Release.
src/Controls/src/Build.Tasks/Controls.Build.Tasks.csproj Packs .mibc files into the Build.Tasks nupkg and copies them into the build tasks output layout.
eng/optimizationData.targets Introduces restore-time download/copy of MIBC optimization data into $(ArtifactsDir)\mibc.
eng/Versions.props Adds the MIBC package version property.
eng/Version.Details.xml Adds dependency flow entry for the MIBC package.
Directory.Build.targets Imports the new optimization data restore logic repo-wide.
Directory.Build.props Defines MibcOptimizationDataDir under $(ArtifactsDir).

@davidnguyen-tech
Copy link
Member Author

/ba-g Test failures are irrelevant - there are the same failures in a build of net11.0 https://dev.azure.com/dnceng-public/public/_build/results?buildId=1277799&view=results

@simonrozsival
Copy link
Member

/azp run maui-pr-uitests,maui-pr-devicetests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Member

@simonrozsival simonrozsival left a comment

Choose a reason for hiding this comment

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

CI failures appear unrelated

@rmarinho rmarinho merged commit 5e0f4e1 into net11.0 Feb 6, 2026
188 of 211 checks passed
@rmarinho rmarinho deleted the android-r2r branch February 6, 2026 11:29
jfversluis pushed a commit that referenced this pull request Mar 5, 2026
<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Summary

Fixes the `UseMonoRuntime` check in the R2R configuration added by
#33234.

`dotnet/android` does not set `UseMonoRuntime` for Release builds — it
leaves the property empty/unset.

**Fix:** Change the condition from `== 'false'` to `!= 'true'` so it
correctly matches when `UseMonoRuntime` is empty (default in Release) or
explicitly set to `false`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot perf/app-size Application Size / Trimming (sub: perf) perf/startup-time Issues relating to startup time (sub: perf) platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android][CoreCLR] Package PGO profiles in the .NET MAUI workload

5 participants