-
Notifications
You must be signed in to change notification settings - Fork 533
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
AOT mode Hybrid does not CIL strip the assemblies that end up in the APK #4818
Comments
obj\InternalRelease\100\android\assets\shrunk obj\InternalRelease\100\android\assets has the stripped versions. |
Same issue with Enterprise 16.7.0 Preview 2.0. The shrunk assemblies do not make it into the apk. If we manually unpack the app and put the stripped versions back in we get
|
Looks like others are having this issue too. https://forums.xamarin.com/discussion/182826/hybrid-aot |
Visual Studio 16.3.10 and MSBuild 16.3.2+e481bbf88 builds an APK with the correctly shrunk .dll. Microsoft Visual Studio Enterprise 2019 (3) Installed Version: Enterprise Azure App Service Tools v3.0.0 16.3.286.43615 C# Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b Common Azure Tools 1.10 Extensibility Message Bus 1.2.0 (d16-2@8b56e20) IntelliCode Extension 1.0 Microsoft JVM Debugger 1.0 Microsoft MI-Based Debugger 1.0 Mono Debugging for Visual Studio 16.3.7 (9d260c5) NuGet Package Manager 5.3.1 ProjectServicesPackage Extension 1.0 Visual Basic Tools 3.3.1-beta3-19461-02+2fd12c210e22f7d6245805c60340f6a34af6875b Visual F# Tools 10.4 for F# 4.6 16.3.0-beta.19455.1+0422ff293bb2cc722fe5021b85ef50378a9af823 Visual Studio Code Debug Adapter Host Package 1.0 VisualStudio.Mac 1.0 Xamarin 16.3.0.281 (d16-3@859f726) Xamarin Designer 16.3.0.256 (remotes/origin/d16-3@8a223bfd7) Xamarin Templates 16.3.565 (27e9746) Xamarin.Android SDK 10.0.6.2 (d16-3/c407838) Xamarin.iOS and Xamarin.Mac SDK 13.6.0.12 (e3c2b40) |
Maybe this is the culprit??? |
Fixes: dotnet#4818 Use of Hybrid AOT currently results in assemblies that have not been CIL-stripped. In 77ab240, a change was made to fix how `Mono.Android.dll` was treated during AOT. `Mono.Android.dll` used to be the only assembly copied to the `shrunk` directory, and we had two copies of the this assembly passed to the AOT compiler. This change unintentionally made `<CilStrip/>` strip the wrong set of assemblies... The initial fix would be: <CilStrip ... - ResolvedAssemblies="@(_ResolvedAssemblies)"> + ResolvedAssemblies="@(_ShrunkAssemblies)"> Unfortunately, this causes a crash: 06-11 16:19:08.557 E/AndroidRuntime(18806): java.lang.UnsatisfiedLinkError: No implementation found for void mono.android.TypeManager.n_activate(java.lang.String, java.lang.String, java.lang.Object, java.lang.Object[]) (tried Java_mono_android_TypeManager_n_1activate and Java_mono_android_TypeManager_n_1activate__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2_3Ljava_lang_Object_2) 06-11 16:19:08.557 E/AndroidRuntime(18806): at mono.android.TypeManager.n_activate(Native Method) 06-11 16:19:08.557 E/AndroidRuntime(18806): at mono.android.TypeManager.Activate(:7) 06-11 16:19:08.557 E/AndroidRuntime(18806): at crc64446c24ccf511bf5f.SplashScreenActivity.<init>(:25) 06-11 16:19:08.557 E/AndroidRuntime(18806): at java.lang.Class.newInstance(Native Method) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.Instrumentation.newActivity(Instrumentation.java:1086) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.-wrap14(ActivityThread.java) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.os.Handler.dispatchMessage(Handler.java:102) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.os.Looper.loop(Looper.java:154) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.main(ActivityThread.java:6682) 06-11 16:19:08.557 E/AndroidRuntime(18806): at java.lang.reflect.Method.invoke(Native Method) 06-11 16:19:08.557 E/AndroidRuntime(18806): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 06-11 16:19:08.557 E/AndroidRuntime(18806): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) Thinking about how things "used to work", we weren't stripping the *correct* `Mono.Android.dll`. So we could run `<CilStrip/>` on every assembly *besides* `Mono.Android.dll`? I think this could be improved further if we could strip `Mono.Android.dll`, but this at least gets things back to working the way they used to. I updated the `BuildIncrementalAot` test that had a `//TODO` comment, which works properly now. I also added a new test to check that method bodies are stripped.
Fixes: dotnet#4818 Use of Hybrid AOT currently results in assemblies that have not been CIL-stripped. In 77ab240, a change was made to fix how `Mono.Android.dll` was treated during AOT. `Mono.Android.dll` used to be the only assembly copied to the `shrunk` directory, and we had two copies of the this assembly passed to the AOT compiler. This change unintentionally made `<CilStrip/>` strip the wrong set of assemblies... The initial fix would be: <CilStrip ... - ResolvedAssemblies="@(_ResolvedAssemblies)"> + ResolvedAssemblies="@(_ShrunkAssemblies)"> Unfortunately, this causes a crash: 06-11 16:19:08.557 E/AndroidRuntime(18806): java.lang.UnsatisfiedLinkError: No implementation found for void mono.android.TypeManager.n_activate(java.lang.String, java.lang.String, java.lang.Object, java.lang.Object[]) (tried Java_mono_android_TypeManager_n_1activate and Java_mono_android_TypeManager_n_1activate__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2_3Ljava_lang_Object_2) 06-11 16:19:08.557 E/AndroidRuntime(18806): at mono.android.TypeManager.n_activate(Native Method) 06-11 16:19:08.557 E/AndroidRuntime(18806): at mono.android.TypeManager.Activate(:7) 06-11 16:19:08.557 E/AndroidRuntime(18806): at crc64446c24ccf511bf5f.SplashScreenActivity.<init>(:25) 06-11 16:19:08.557 E/AndroidRuntime(18806): at java.lang.Class.newInstance(Native Method) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.Instrumentation.newActivity(Instrumentation.java:1086) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.-wrap14(ActivityThread.java) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.os.Handler.dispatchMessage(Handler.java:102) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.os.Looper.loop(Looper.java:154) 06-11 16:19:08.557 E/AndroidRuntime(18806): at android.app.ActivityThread.main(ActivityThread.java:6682) 06-11 16:19:08.557 E/AndroidRuntime(18806): at java.lang.reflect.Method.invoke(Native Method) 06-11 16:19:08.557 E/AndroidRuntime(18806): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 06-11 16:19:08.557 E/AndroidRuntime(18806): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) Thinking about how things "used to work", we weren't stripping the *correct* `Mono.Android.dll`. So we could run `<CilStrip/>` on every assembly *besides* `Mono.Android.dll`? I think this could be improved further if we could strip `Mono.Android.dll`, but this at least gets things back to working the way they used to. I updated the `BuildIncrementalAot` test that had a `//TODO` comment, which works properly now. I also added a new test to check that method bodies are stripped.
Fixes: #4818 Use of Hybrid AOT currently results in assemblies that have not been CIL-stripped. In 77ab240, a change was made to fix how `Mono.Android.dll` was treated during AOT. `Mono.Android.dll` used to be the only assembly copied to the `shrunk` directory, and we had two copies of the this assembly passed to the AOT compiler. This change unintentionally made `<CilStrip/>` strip the wrong set of assemblies... The initial fix would be: <CilStrip ... - ResolvedAssemblies="@(_ResolvedAssemblies)"> + ResolvedAssemblies="@(_ShrunkAssemblies)"> Unfortunately, this causes a crash: E/AndroidRuntime(18806): java.lang.UnsatisfiedLinkError: No implementation found for void mono.android.TypeManager.n_activate(java.lang.String, java.lang.String, java.lang.Object, java.lang.Object[]) (tried Java_mono_android_TypeManager_n_1activate and Java_mono_android_TypeManager_n_1activate__Ljava_lang_String_2Ljava_lang_String_2Ljava_lang_Object_2_3Ljava_lang_Object_2) E/AndroidRuntime(18806): at mono.android.TypeManager.n_activate(Native Method) E/AndroidRuntime(18806): at mono.android.TypeManager.Activate(:7) E/AndroidRuntime(18806): at crc64446c24ccf511bf5f.SplashScreenActivity.<init>(:25) E/AndroidRuntime(18806): at java.lang.Class.newInstance(Native Method) E/AndroidRuntime(18806): at android.app.Instrumentation.newActivity(Instrumentation.java:1086) E/AndroidRuntime(18806): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809) E/AndroidRuntime(18806): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) E/AndroidRuntime(18806): at android.app.ActivityThread.-wrap14(ActivityThread.java) E/AndroidRuntime(18806): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) E/AndroidRuntime(18806): at android.os.Handler.dispatchMessage(Handler.java:102) E/AndroidRuntime(18806): at android.os.Looper.loop(Looper.java:154) E/AndroidRuntime(18806): at android.app.ActivityThread.main(ActivityThread.java:6682) E/AndroidRuntime(18806): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(18806): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) E/AndroidRuntime(18806): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) Thinking about how things "used to work", we weren't stripping the *correct* `Mono.Android.dll`. So we could run `<CilStrip/>` on every assembly *besides* `Mono.Android.dll`? I think this could be improved further if we could strip `Mono.Android.dll`, but this at least gets things back to working the way they used to. I updated the `BuildTest.BuildIncrementalAot()` test that had a `//TODO` comment, as it works properly now. I also added a new test to check that method bodies are stripped.
When will this fix go live please? |
@taublast Currently, it looks like this will be in a future Visual Studio 2019 16.8 version. |
Release status update A new Preview version of Xamarin.Android has now been published that includes the fix for this item. The fix is not yet included in a Release version. I will update this item again when a Release version is available that includes the fix. Fix included in Xamarin.Android SDK version 11.0.99.9. Fix included on Windows in Visual Studio 2019 version 16.8 Preview 1. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview. Fix included on macOS in Visual Studio 2019 for Mac version 8.8 Preview 1. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel. |
Release status update A new Release version of Xamarin.Android has now been published that includes the fix for this item. Fix included in Xamarin.Android SDK version 11.1.0.17. Fix included on Windows in Visual Studio 2019 version 16.8. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/. Fix included on macOS in Visual Studio 2019 for Mac version 8.8. To get the new version that includes the fix, check for the latest updates on the Stable updater channel. |
Steps to Reproduce
Expected Behavior
.dll in the assemblies dir of the apk are stripped. App runs correctly.
Xamarin.Android.common.targets has a block that should do this when AOT and Hybrid is enabled.
Actual Behavior
.dll in the assemblies dir of the apk are completely intact. App crashes
obj\InternalRelease\100\android\assets\shrunk has the method bodies stripped out but these don't make it into the final apk.
Partial work around
I changed Xamarin.Android.common.targets to use
ResolvedAssemblies="@(_ShrunkAssemblies)"
.The stripped assemblies now end up in the apk but when I connect the debugger the app is crashing on launch due to:
Version Information
Microsoft Visual Studio Enterprise 2019 (2)
Version 16.6.1
VisualStudio.16.Release/16.6.1+30128.74
Microsoft .NET Framework
Version 4.8.03761
Installed Version: Enterprise
Azure App Service Tools v3.0.0 16.6.936.3669
Azure App Service Tools v3.0.0
C# Tools 3.6.0-4.20251.5+910223b64f108fcf039012e0849befb46ace6e66
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info
JetBrains ReSharper Ultimate 2020.1.3 Build 201.0.20200515.122017
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2020 JetBrains, Inc.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Mono Debugging for Visual Studio 16.6.17 (9692114)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 5.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
Visual Basic Tools 3.6.0-4.20251.5+910223b64f108fcf039012e0849befb46ace6e66
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 10.9.1.0 for F# 4.7 16.6.0-beta.20217.4+1c969cac25e2d38d71872efe6c8226029e42bb59
Microsoft Visual F# Tools 10.9.1.0 for F# 4.7
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Foo 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 16.6.000.1061 (d16-6@8e68aa8)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 16.6.0.318 (remotes/origin/d16-6@66afc5421)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.6.40 (1f1466f)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 10.3.1.4 (d16-6/3a10de9)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard@905836d
SQLite: xamarin/sqlite@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3
Xamarin.iOS and Xamarin.Mac SDK 13.18.2.1 (29c4ea7)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Log File
BuildLogTargetsWorkAround.zip
BuildlogOriginalTargets.zip
The text was updated successfully, but these errors were encountered: