-
Notifications
You must be signed in to change notification settings - Fork 537
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
[trimmer] pass --disable-opt unusedtypechecks
#9435
Conversation
An alternative to: #9411
@@ -18,7 +18,7 @@ | |||
|
|||
<PropertyGroup> | |||
<!-- APK tests might run on 32-bit emulators --> | |||
<RuntimeIdentifiers>android-arm64;android-x86;android-x64;</RuntimeIdentifiers> | |||
<RuntimeIdentifiers Condition=" '$(RuntimeIdentifier)' == '' ">android-arm64;android-x86;android-x64;</RuntimeIdentifiers> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the PR description to explain/describe this change as well.
@sbomer FYI I must admit I'm not a fan of this solution. It basically says that we know there are trimming holes in the system and we're going to try to avoid them by disabling certain optimizations in the trimmer. The problem is that trimmer may make similar assumptions elsewhere and we didn't catch it yet - or it will start to do so in the next release for example. |
Linux tests keep failing for "bizarre" reasons:
Retrying the whole thing. |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
@vitek-karas yes, @sbomer and I chose this as a better idea than #9411. We would like to find a better solution later, especially if there is NativeAOT support for Android. Perhaps .NET 10? |
I don't think this is a reliable long-term solution, but my understanding from conversation with @jonathanpeppers is that we don't have a way to know ahead of time which types may be created from java. For future reference, this fix is effectively adding a heuristic that says "if there is a type check for a type (and it implements IJavaObject), then assume it may be created from the java side". If we had a source of truth that could tell us which IJavaObject implementors need to be kept, we could rely on that instead and the type check removal optimization wouldn't cause problems. |
Fixes: #9399
An alternative to: #9411
The .NET trimmer will inline cast statements such as:
If
NinePatchDrawable
is not "instantiated" anywhere vianew()
, inlined to:We can solve this by passing
--disable-opt unusedtypechecks
, with$(_AndroidEnableUnusedTypeChecks)
as a private MSBuild property to opt out if needed.Since Java can create these objects, this feels like the reasonable fix for .NET 9 GA.
I also fixed the
$(RuntimeIdentifiers)
inTestApks.targets
to check if someone passed-r android-arm64
, for example.