Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[XABT] Don't run
AddKeepAlivesStep
on .NET for Android assemblies. (#…
…9823) Fixes: #8421 Context: dotnet/java-interop#719 Context: #5278 In dotnet/java-interop#719, we realized we needed to call `GC.KeepAlive ()` on objects that are passed to native code to prevent the GC from collecting them prematurely. However, this only solved the issue for newly compiled binding libraries and not the existing ecosystem of binding libraries. Thus we added #5278, a "linker" step that would add `GC.KeepAlive ()` calls to existing binding libraries. The `AddKeepAlivesStep` runs on all assemblies the contain a reference to `Java.Lang.Object`, including ones that already have the keep-alives compiled in. Modify the step to skip assemblies that are built against .NET for Android, as we know they have the compiled keep-alives. Technically we could go back to Xamarin.Android 11.1, but using .NET for Android as the cutoff will easily filter out the vast majority of binding libraries. This results in decent savings for the following test case: ``` dotnet new android dotnet add package Xamarin.AndroidX.Activity --version 1.9.3.1 dotnet build -p:AndroidAddKeepAlives=true ``` | Scenario (`_LinkAssembliesNoShrink`) | This PR | main | | -------- | ------- | ------ | | Full | 4.19 s | 4.72 s | However, in cases like #8421 where this step seems to be taking an abnormal amount of time there should be substantial improvements.
- Loading branch information