Repository navigation
Debug feature broken on Android 9 with VS2019 & VS2022 #7658
Description
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.)
Affected platform version
VS2022 17.4.3 / VS2019 16.9.3
Description
There are big stability issues when debugging a Xamarin.Android app with VS2022 or VS2019.
We are using Android x86 (Android version 9 - Pie) to debug our app in a VMware virtual machine because the app needs to be deployed on an embedded system that uses Android Pie.
Also we have the same issues with real android 9 device based on ARM processor so it is not linked to x86, I talk about it here because it is a good neutral environment to reproduce the issue.
We tried running with different development environment, in VS2019 and VS2022, and here are the issues we faced:
With VS2022
- Exceptions filter do not work at all: either all exceptions are activated or none.
- Also we need to check "Use Fast Deployment" to be able to launch the app at all. For some reason it makes launching the app unusually slow. And anyway the exceptions filters don't work so debugging is hard.
When Fast Deployment is unchecked in our app we get the following log in debug output:
[Random.App] Unexpected CPU variant for X86 using defaults: x86_64
[monodroid] Creating public update directory:/data/user/0/Some.Random.App/files/.__override__
[meZero.BillFis] Attempt to remove non-JNI local reference, dumping thread
[monodroid-debug] Trying to initialize the debugger with options: --debugger-agent=transport=dt_socket,loglevel=0,address=127.0.0.1:8822,server=y,embedding=1
[monodroid-assembly] Failed to load managed assembly 'mscorlib.dll'. Internal error
[monodroid-assembly] open_from_bundles: failed to load assembly mscorlib.dll
[mono] The assembly mscorlib.dll was not found or could not be loaded.
[mono] It should have been installed in the `/Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/sdks/out/android-x86-release/lib/mono/2.1/mscorlib.dll' directory.
With VS2019
- When we use the exceptions filters, we cannot change them dynamically: when we do it the changes don't apply. So we are stuck using the filters we set when starting the debug session.
- When debugging sometimes the debugger crashes with no error message when staying on a breakpoint for too long, or trying to display information about a local variable value.
- When debugging sometimes the debugger crashes with an exception:
EXCEPTION: Mono.Debugger.Soft.VMNotSuspendedException: The vm is not suspended.
at Mono.Debugger.Soft.VirtualMachine.ErrorHandler(Object sender, ErrorHandlerEventArgs args) in C:\A\1\216\s\external\debugger-libs\Mono.Debugger.Soft\Mono.Debugger.Soft\VirtualMachine.cs:line 367
at Mono.Debugger.Soft.Connection.SendReceive(CommandSet command_set, Int32 command, PacketWriter packet) in C:\A\1\216\s\external\debugger-libs\Mono.Debugger.Soft\Mono.Debugger.Soft\Connection.cs:line 1805
at Mono.Debugger.Soft.VirtualMachine.Resume() in C:\A\1\216\s\external\debugger-libs\Mono.Debugger.Soft\Mono.Debugger.Soft\VirtualMachine.cs:line 139
at Mono.Debugging.Soft.SoftDebuggerSession.HandleEventSet(EventSet es) in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1714
at Mono.Debugging.Soft.SoftDebuggerSession.EventHandler() in C:\A\1\216\s\external\debugger-libs\Mono.Debugging.Soft\SoftDebuggerSession.cs:line 1615
Those issues with VS2019 & 2022 are hindering a lot our debugging efficiency, since the issues with VS2022 made us prefer VS2019, but often we crash just trying to get information about a variable.
Is there any way to work around these issues, or to solve them? The best would be that all works fine in VS2022 so we could forget about VS2019 all together.
Below are the version information:
VS2022
Microsoft Visual Studio Enterprise 2022
Version 17.4.3
VisualStudio.17.Release/17.4.3+33205.214
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Enterprise
Visual C++ 2022 00482-20050-05733-AA863
Microsoft Visual C++ 2022
ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools
ASA Service Provider 1.0
ASP.NET and Web Tools 17.4.326.54890
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.4.326.54890
Azure App Service Tools v3.0.0
Azure Data Lake Tools for Visual Studio 2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio
Azure Functions and Web Jobs Tools 17.4.326.54890
Azure Functions and Web Jobs Tools
Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio
C# Tools 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14
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.
Cookiecutter 17.0.22263.6
Provides tools for finding, instantiating and customizing templates in cookiecutter format.
Extensibility Message Bus 1.4.1 (main@2ee106a)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
Linux Core Dump Debugging 1.0.9.33020
Enables debugging of Linux core dumps.
Microsoft Azure Hive Query Language Service 2.6.5000.0
Language service for Hive query
Microsoft Azure Stream Analytics Language Service 2.6.5000.0
Language service for Azure Stream Analytics
Microsoft Azure Tools for Visual Studio 2.9
Support for Azure Cloud Services projects
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Mono Debugging for Visual Studio 17.4.19 (8c0a575)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 6.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Python - Profiling support 17.0.22263.6
Profiling support for Python projects.
Python with Pylance 17.0.22263.6
Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers.
Razor (ASP.NET Core) 17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.0.62207.28050
Microsoft SQL Server Data Tools
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
ToolWindowHostedEditor 1.0
Hosting json editor into a tool window
TypeScript Tools 17.0.10921.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.4.0-6.22580.4+d7a61210a88b584ca0827585ec6e871c6b1c5a14
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual C++ for Linux Development 1.0.9.33020
Visual C++ for Linux Development
Visual F# Tools 17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
VSPackage Extension 1.0
VSPackage Visual Studio Extension Detailed Info
Xamarin 17.4.0.312 (d17-4@be7e8d1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 17.4.0.138 (remotes/origin/d17-4@d36bba3cc9)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 17.4.2 (c457c97)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 13.1.0.1 (d17-4/13ba222)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: a96bde9
Java.Interop: xamarin/java.interop/d17-4@fcc33ce2
SQLite: xamarin/sqlite/3.39.3@23e1ae7
Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a
Xamarin.iOS and Xamarin.Mac SDK 16.1.1.27 (933c6c2c9)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
VS2019
Microsoft Visual Studio Enterprise 2019 (2)
Version 16.9.3
VisualStudio.16.Release/16.9.3+31129.286
Microsoft .NET Framework
Version 4.8.04084
Installed Version: Enterprise
Architecture Diagrams and Analysis Tools 00433-90100-10153-AA695
Microsoft Architecture Diagrams and Analysis Tools
Visual C++ 2019 00433-90100-10153-AA695
Microsoft Visual C++ 2019
.NET Portability Analyzer 1.1.10808.0
Evaluates portability of assemblies across .NET platforms.
ASP.NET and Web Tools 2019 16.9.693.2781
ASP.NET and Web Tools 2019
ASP.NET Core Razor Language Services 16.1.0.2112521+5741df381174d72f08e3632bb99f52e8635b6a1a
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2019 16.9.693.2781
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 16.9.693.2781
Azure App Service Tools v3.0.0
C# Tools 3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
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.6 (master@34d6af2)
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
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.40218.1
Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft Library Manager 2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 16.9.7 (df23ba6)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 5.9.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Productivity Power Tools 2017/2019 16.0
Installs the individual extensions of Productivity Power Tools 2017/2019
ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info
SQL Server Data Tools 16.0.62103.10080
Microsoft SQL Server Data Tools
Syntax Visualizer 1.0
An extension for visualizing Roslyn SyntaxTrees.
Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.
Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.
TFS Source Control Explorer Extension 1.0
Visual Studio Extension for Team Foundation Server Source Control Explorer
TypeScript Tools 16.0.30201.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 3.9.0-6.21160.10+59eedc33d35754759994155ea2f4e1012a9951e3
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 16.9.0-beta.21102.9+7ce7132f1459095e635194d09d6f73265352029a
Microsoft Visual F# Tools
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Container Tools Extensions 1.0
View, manage, and diagnose containers within Visual Studio.
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers
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
WiX Toolset Visual Studio Extension 1.0.0.18
WiX Toolset Visual Studio Extension version 1.0.0.18
Copyright (c) .NET Foundation and contributors. All rights reserved.
Xamarin 16.9.000.273 (d16-9@1bba9e0)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 16.9.0.316 (remotes/origin/d16-9@fdbf64026)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin Templates 16.9.68 (8e9b569)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.
Xamarin.Android SDK 11.2.2.1 (d16-9/877f572)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: 5e9cb6d
Java.Interop: xamarin/java.interop/d16-9@54f8c24
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.34.1@daff8f4
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-9@d210f11
Xamarin.iOS and Xamarin.Mac SDK 14.14.2.5 (3836759d4)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
Steps to Reproduce
With VS2022:
- Install Android 9.0 in VMware by using Android x86.
(vmware image can be downloaded from here: https://www.osboxes.org/android-x86/#android-x86-9-0-r2-vmware) - Create a Xamarin Android app and uncheck "Use Fast Deployment" in project properties.
- Run the application in Debug attached.
Result:
- The app won't launch if "Use Fast Deployment" is not checked
- If Fast Deployment is used, the app will take an usual long time to launch.
- The exception filters cannot be used.
Note: when launching the app there is a warning about exception filters:
This debug engine does not support exception conditions. The condition(s) will be ignored.
With VS2019:
- Install Android 9.0 in VMware by using Android x86.
(vmware image can be downloaded from here: https://www.osboxes.org/android-x86/#android-x86-9-0-r2-vmware) - Create a Xamarin Android app.
- Run the application in Debug attached and perform usual debug operations (stop on breakpoints, check variable contents like lists etc., use some async await in the application and check list contents (you can for example try to list tasks from an azure job asynchronously and check the enumeration contents)).
Result:
When performing normal debug operations like stopping on a breakpoint for some time or checking local variables or list contents the debugger crashes (resulting in application crash or freeze).
Did you find any workaround?
No response
Relevant log output
No response
Activity
dellis1972 commentedon Jan 4, 2023
@jiro-san
I suspect your issue might be that the
AndroidSupportedAbisvalue defaults toarmeabi-v7a;arm64-v8awhen you are not usingFast Deployment.can you try adding the following to your
Debugconfiguration in your main apps csproj?This will ensure that the x84 (or x86_64) native libraries are included in the applicastion package.
As for the Filter Exceptions you will need to report tht issue via the Visual Studio 'Report an issue' menu item since it is a different team which deals with that.
jiro-san commentedon Jan 4, 2023
Our app is using .so files compiled for armeabi-v7a, and we don't have the version for arm64-v8a yet. If we enable arm64-v8a we get "[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.NotSupportedException" when trying to initialize our so file.
We will try getting support for x64-v8a too, but since x64-v8a ARM CPUs are also compatible with armeabi-v7a libraries (I didn't have time yet to look for the official information from ARM but it works when we try our app, without debugging), I did not expect this issue.
Also it does not happen with the VS2019 environment.
So we will try to add x64-v8a support, but if you can please comment if you see it as a bug or as an expected behavior.
dellis1972 commentedon Jan 4, 2023
So we are going to need some diagnsotic build logs since I am unable to repo the VMWare issue with the Android x86 Image you linked to.
So from a developer command prompt can you run the following command on your project after deleting the bin & obj directories. Do this against your Android 9 device , not the VMWare image.
This will produce a msbuild.binlog file which you can zip up and sent do us.
next from an Android Command Prompt (There should be a menu item in VS) run
Then run the app on the device. Once the app crashes presss Ctrl-C to exit
adb logcatand upload the adb.log file as well.This should contain the info we need to investigte further.
jiro-san commentedon Jan 4, 2023
Hello, oh ok sorry i was not clear, you can reproduce the same issue with an app that uses x86 libraries (.so files) running on the VM i provided (the VM runs with x86_64 architecture, so what we said about armeabi-v7a and arm64-v8a also applies here).
On our side our app uses x86 and armeabi-v7a abis, so we need libs for x86_64 and arm64-v8a to test your proposal, but I am sure you can reproduce it if you deploy on x86_64 with an app that supports only x86 abi.
28 remaining items
[loader] Set status on success (dotnet#80949)
[mono][loader] Set status on success; avoid mmap on Android (#21609)
[loader] Set status on success (#80951)
jlinker7 commentedon Feb 10, 2023
I am experiencing the same issue (though running on a custom android device running Android 7.1.1). Any idea when the proposed fix will be released in an update to Mono.Android?
teo-tsirpanis commentedon Mar 22, 2023
Can we close it? The issue has been fixed and backported.
Bump to mono/mono@73df89a7
jonpryor commentedon May 19, 2023
I can't believe I forgot about this! #8054
@teo-tsirpanis: .NET 7 has had the fix backported. Classic Xamarin.Android has not (oops), and #8054 does so.
jlinker7 commentedon May 19, 2023
@jonpryor Do we have any idea when this will be released? It's killing me not being able to debug my app...
Bump to mono/mono@73df89a7 (#8054)
chrisz99 commentedon Jun 16, 2023
Same
[mono][loader] Set status on success; avoid mmap on Android (mono#21609)
jpobst commentedon May 17, 2024
This seems to be fixed in .NET 8+.