Summary
maui profile startup skips build injection on iOS and Mac Catalyst, requiring users to manually reference Microsoft.Maui.StartupProfiling and call StartupProfilingMarker.Complete(). On Android, this is handled automatically.
Current behavior
In ProfileSessionSetup.cs (line 50-51):
context.BuildInjection = string.Equals(profilePlatform, Platforms.iOS, StringComparison.OrdinalIgnoreCase)
? null
: ProfileCommandBuildInjectionResolver.TryCreateBuildInjection(...);
iOS is unconditionally set to null, which disables:
- Auto-injection of
StartupProfilingMarker (the AutoInitialize.cs module initializer)
- The
StartupProfiling.dll assembly reference
- Environment variable configuration for EventPipe/PGO
Why it should work
The injected bootstrap code (MauiStartupProfiling.AutoInitialize.cs) is platform-agnostic managed C# — a module initializer that polls for the main page and fires StartupProfilingMarker.Complete(). Nothing in it is Android-specific.
The only Android-specific part is the GenerateMauiStartupProfilingEnvironment MSBuild target, which writes an <AndroidEnvironment> file for runtime-owned EventPipe collection. This target is already conditioned on -android in the .targets file, so it would simply not run on iOS/Mac Catalyst.
Expected behavior
maui profile startup --project MyApp.csproj -f net10.0-ios should auto-inject the startup marker, just like it does for Android. Users should not need to manually reference the package or call Complete().
Scope
- Remove the iOS platform check at
ProfileSessionSetup.cs:50-51
- Verify build injection works on iOS simulator and Mac Catalyst
- Consider adding an equivalent environment variable mechanism for iOS if runtime-owned EventPipe collection is needed (analogous to
<AndroidEnvironment>)
Summary
maui profile startupskips build injection on iOS and Mac Catalyst, requiring users to manually referenceMicrosoft.Maui.StartupProfilingand callStartupProfilingMarker.Complete(). On Android, this is handled automatically.Current behavior
In
ProfileSessionSetup.cs(line 50-51):iOS is unconditionally set to
null, which disables:StartupProfilingMarker(theAutoInitialize.csmodule initializer)StartupProfiling.dllassembly referenceWhy it should work
The injected bootstrap code (
MauiStartupProfiling.AutoInitialize.cs) is platform-agnostic managed C# — a module initializer that polls for the main page and firesStartupProfilingMarker.Complete(). Nothing in it is Android-specific.The only Android-specific part is the
GenerateMauiStartupProfilingEnvironmentMSBuild target, which writes an<AndroidEnvironment>file for runtime-owned EventPipe collection. This target is already conditioned on-androidin the.targetsfile, so it would simply not run on iOS/Mac Catalyst.Expected behavior
maui profile startup --project MyApp.csproj -f net10.0-iosshould auto-inject the startup marker, just like it does for Android. Users should not need to manually reference the package or callComplete().Scope
ProfileSessionSetup.cs:50-51<AndroidEnvironment>)