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

Improve XA0141 warning #9544

Closed
jpobst opened this issue Nov 21, 2024 · 5 comments
Closed

Improve XA0141 warning #9544

jpobst opened this issue Nov 21, 2024 · 5 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.

Comments

@jpobst
Copy link
Contributor

jpobst commented Nov 21, 2024

.NET 9.0.100

The NuGet package information in the XA0141 warning seems helpful, but it doesn't appear to actually work.

Repro:

dotnet new android
dotnet add package Xamarin.GooglePlayServices.Vision.Face.Contour.Internal --version 116.1.0.19
dotnet build -c Release

results in:

warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so' which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details
warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so' which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details

We should:

  • Either fix the NuGet information to be more accurate or remove it.
  • Maybe add the arch information to the file name (arm64-v8a/libface_detector_v2_jni.so), as each package will likely contain many versions with the same file name.
  • Rewrite the warning to be a little less scary, emphasizing this is a future problem, not necessarily something that needs to be fixed today. ("is not correctly aligned" sounds like the library is broken today)

An updated example:

warning XA0141: NuGet package 'Xamarin.GooglePlayServices.Vision.Face.Contour.Internal' version '116.1.0.19' contains a shared library 'arm64-v8a/libface_detector_v2_jni.so' which is not 16KB aligned. Google may require 16KB aligned libraries in the future. See https://developer.android.com/guide/practices/page-sizes for more details.
@jpobst jpobst added the Area: App+Library Build Issues when building Library projects or Application projects. label Nov 21, 2024
@jpobst jpobst added this to the .NET 9 Servicing milestone Nov 21, 2024
@dotnet-policy-service dotnet-policy-service bot added the needs-triage Issues that need to be assigned. label Nov 21, 2024
@jpobst jpobst removed the needs-triage Issues that need to be assigned. label Nov 21, 2024
@grendello
Copy link
Contributor

I think @dellis1972 looked into it sometime ago and determined that the information isn't available for transient packages. I'll see to adding arch information, but I can't do much about getting better nuget info. I'll leave that to @dellis1972 and @jonathanpeppers :)

grendello added a commit that referenced this issue Nov 22, 2024
Partial fix for #9544 to make
the warning more informative.  Architecture information is necessary as
the nuget in question might have the same library for various
architectures.
@grendello
Copy link
Contributor

Partial fix: #9547

grendello added a commit that referenced this issue Nov 22, 2024
Partial fix for #9544 to make
the warning more informative.  Architecture information is necessary as
the nuget in question might have the same library for various
architectures.
@jonpryor
Copy link
Member

This is going to require a fair bit of "plumbing" that I don't currently understand.

Working backwards:

  • libface_detector_v2_jni.so comes from obj/Release/net9.0-android/lp/92/jl/jni/armeabi-v7a/libface_detector_v2_jni.so, obj/Release/net9.0-android/lp/76/jl/jni/armeabi-v7a/libface_detector_v2_jni.so
  • as per obj/Release/net9.0-android/lp/map.cache:
    • obj/Release/net9.0-android/lp/92 is from playservicesvisionfacecontourinternal-16.1.0.aar
    • obj/Release/net9.0-android/lp/76 is from play-services-vision-face-contour-internal.aar
  • Both playservicesvisionfacecontourinternal-16.1.0.aar and play-services-vision-face-contour-internal.aar are from @(XamarinBuildDownload) artifacts, e.g.
    11:04:44.957   1:7>Target "_XbdRestoreItems_playservicesvisionfacecontourinternal_16_1_0: (TargetId:147)" in file "$HOME/.nuget/packages/xamarin.googleplayservices.vision.face.contour.internal/116.1.0.19/buildTransitive/net8.0-android34.0/Xamarin.GooglePlayServices.Vision.Face.Contour.Internal.targets" from project "/Volumes/Xamarin-Work/tmp/gda-9544/gda-9544.csproj" (target "_XamarinBuildAddDownloadedItems" depends on it):
                       Added Item(s): 
                           XamarinBuildDownload=
                               playservicesvisionfacecontourinternal-16.1.0
                                       Kind=Uncompressed
                                       Sha256=
                                       ToFile=playservicesvisionfacecontourinternal-16.1.0.aar
                                       Url=https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-vision-face-contour-internal/16.1.0/play-services-vision-face-contour-internal-16.1.0.aar
    
  • Ergo, play-services-vision-face-contour-internal-16.1.0.aar comes from the Xamarin.GooglePlayServices.Vision.Face.Contour.Internal NuGet package.

How do we provide enough information/metadata/etc. for <BuildApk/>, when given obj/Release/net9.0-android/lp/92/jl/jni/armeabi-v7a/libface_detector_v2_jni.so, that it can "work backwards" and determine that it comes from the Xamarin.GooglePlayServices.Vision.Face.Contour.Internal NuGet package?

@grendello
Copy link
Contributor

grendello commented Nov 22, 2024

Nuget information can be propagated to the .so ITaskItem from the _ReferencePath item, which has all the nuget info.

grendello added a commit that referenced this issue Nov 22, 2024
Partial fix for #9544 to make
the warning more informative.  Architecture information is necessary as
the nuget in question might have the same library for various
architectures.
grendello added a commit that referenced this issue Nov 27, 2024
Partial fix for #9544 to make
the warning more informative.  Architecture information is necessary as
the nuget in question might have the same library for various
architectures.
@jonpryor
Copy link
Member

jonpryor commented Dec 9, 2024

See also: #9559

grendello added a commit that referenced this issue Jan 7, 2025
Partial fix for #9544 to make
the warning more informative.  Architecture information is necessary as
the nuget in question might have the same library for various
architectures.
jonpryor pushed a commit that referenced this issue Jan 27, 2025
Fixes: #9544

Context: 64bb147

[Google announced][0] that future versions of Android would require
that native libraries use 16 KB page sizes on arm64.  At present, the
timeline for *when* 16 KB page sizes will be required is unknown,
though we assume it will be with Android 16 or later.

In order to get ahead of this, .NET 9 added an XA0141 warning in
64bb147.

The problem is, this warning is not entirely actionable:

	dotnet new android
	dotnet add package Xamarin.GooglePlayServices.Vision.Face.Contour.Internal --version 116.1.0.19
	dotnet build -c Release

results in:

	warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so'
	  which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details
	warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so'
	  which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details

What are customers supposed to *do* with this?

The original assumption was that the NuGet package and Version would
be available as metadata items on the MSBuild Items.  Unfortunately
that was not the case, so the data the user gets is empty.

Add the required metadata to all NuGet Package references resolved by
the project.  This will allow us to propagate that data throughout
the build Items as they are transformed.  This means we can provide a
decent error message to the user:

	warning XA0141: Android 16 will require 16 KB page sizes, shared library 'libface_detector_v2_jni.so' does not have a 16 KB page size.
	  Please inform the authors of the NuGet package 'Xamarin.GooglePlayServices.Vision.Face.Contour.Internal' version '116.1.0.19'
	  which contains 'lib/net8.0-android34.0/play-services-vision-face-contour-internal.aar'.
	  See https://developer.android.com/guide/practices/page-sizes for more details.

[0]: https://android-developers.googleblog.com/2024/08/adding-16-kb-page-size-to-android.html
jonpryor pushed a commit that referenced this issue Jan 28, 2025
Fixes: #9544

Context: 64bb147

[Google announced][0] that future versions of Android would require
that native libraries use 16 KB page sizes on arm64.  At present, the
timeline for *when* 16 KB page sizes will be required is unknown,
though we assume it will be with Android 16 or later.

In order to get ahead of this, .NET 9 added an XA0141 warning in
64bb147.

The problem is, this warning is not entirely actionable:

	dotnet new android
	dotnet add package Xamarin.GooglePlayServices.Vision.Face.Contour.Internal --version 116.1.0.19
	dotnet build -c Release

results in:

	warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so'
	  which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details
	warning XA0141: NuGet package '<unknown>' version '<unknown>' contains a shared library 'libface_detector_v2_jni.so'
	  which is not correctly aligned. See https://developer.android.com/guide/practices/page-sizes for more details

What are customers supposed to *do* with this?

The original assumption was that the NuGet package and Version would
be available as metadata items on the MSBuild Items.  Unfortunately
that was not the case, so the data the user gets is empty.

Add the required metadata to all NuGet Package references resolved by
the project.  This will allow us to propagate that data throughout
the build Items as they are transformed.  This means we can provide a
decent error message to the user:

	warning XA0141: Android 16 will require 16 KB page sizes, shared library 'libface_detector_v2_jni.so' does not have a 16 KB page size.
	  Please inform the authors of the NuGet package 'Xamarin.GooglePlayServices.Vision.Face.Contour.Internal' version '116.1.0.19'
	  which contains 'lib/net8.0-android34.0/play-services-vision-face-contour-internal.aar'.
	  See https://developer.android.com/guide/practices/page-sizes for more details.

[0]: https://android-developers.googleblog.com/2024/08/adding-16-kb-page-size-to-android.html
@github-actions github-actions bot locked and limited conversation to collaborators Feb 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
Development

No branches or pull requests

5 participants