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

Trimming MUST be on for AOT on Android in Release mode, I don't really see why? #18032

Closed
jkommeren opened this issue Oct 15, 2023 · 1 comment
Labels
platform/android 🤖 t/bug Something isn't working

Comments

@jkommeren
Copy link

jkommeren commented Oct 15, 2023

Disclaimer

I read somewhere that Linking and Trimming are the same thing in MAUI context?. In any case I'm referring to the "Optimizing Assembly" build step with the disclaimer "https://aka.ms/dotnet-illink" which takes a long time and is only triggered for Release mode when AOT is on.

Description

Situation: Due to a bug which seems to be related to trimming/"optimizing for size" (which has been in there for ages, #16014), which basically breaks Android Push notifications, at least in the specific case I'm interested in, I figured leaving off Trimming/"optimizing for size" with AOT enabled would get me best of both worlds.

Compiling works fine in Debug mode with AOT and publishtrimmed not set, which does NOT trigger the linking process, which is shown in Output with
Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink

so I'm puzzled why linking/optimizingforsize must be on in release mode:

  • I cannot publish the app to the store in Debug mode,
  • and leaving off AOT deteriorates app startup performance.

The linking bit even comes with it's own disclaimer, but I figured AOT on it's own should be safe?

There's probably a good reason, or there was one at some point, for this behavior. I was interested in the story behind it, and hoping it could have been just a precaution I could work around in another way?

I upgraded to 8.0 rc2 to check if it was still in there. It is unfortunately.

Steps to Reproduce

  1. Create project
  2. Enable AOT for Release mode by setting RunAOTCompilation to true
  3. Disable Trimming by setting PublishTrimmed to False
  4. -compiler error-

Or:

Steps to Reproduce alternative

  1. Create project
  2. Enable AOT for Release mode by setting RunAOTCompilation to true
  3. (don't set publishtrimmed, which sets it to True)
  4. -notification not triggering-

Result:
error XA1030: The 'RunAOTCompilation' MSBuild property is only supported when trimming is enabled. Edit the project file in a text editor to set 'PublishTrimmed' to 'true' for this build configuration.

Link to public reproduction project repository

No response

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Disabling AOT obviously

Relevant log output

error XA1030: The 'RunAOTCompilation' MSBuild property is only supported when trimming is enabled. Edit the project file in a text editor to set 'PublishTrimmed' to 'true' for this build configuration.
@jkommeren jkommeren added the t/bug Something isn't working label Oct 15, 2023
@jkommeren jkommeren changed the title Trimming MUST be on for AOT Trimming MUST be on for AOT, I don't really see why? Oct 15, 2023
@jkommeren jkommeren changed the title Trimming MUST be on for AOT, I don't really see why? Trimming MUST be on for AOT on Android in Release mode, I don't really see why? Oct 15, 2023
@jkommeren
Copy link
Author

Not sure what's going on here. I need to do some more investigation

@dotnet dotnet locked as resolved and limited conversation to collaborators Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants