dotnet / android

.NET for Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
MIT License
1.94k stars 533 forks source link

Activities are leaking according to strict mode #3509

Open heytherewill opened 5 years ago

heytherewill commented 5 years ago

Steps to Reproduce

  1. File -> New Project... -> Android App (Xamarin)
  2. Replace the contents of MainActivity.cs with the contents of this gist
  3. Run the project
  4. Tap the fab to start an activity, close it and then tap the fab again

Expected Behavior

Logcat should not show any violations, since simply starting an Activity does not leak anything (at least not on

Actual Behavior

Logcat shows a violation of the policy because the activities are leaking. We found this while working on our apps, but since this is reproducible with such a small app, the problem is definitely elsewhere.

Now I'm not sure if this is a false positive, but if it is it renders activity leak detection on Xamarin.Android''s StrictMode useless, which is also bad but not as bad as having all activities actually leaking.

Version Information

Microsoft Visual Studio Community 2019 Version 16.2.0 VisualStudio.16.Release/16.2.0+29123.88 Microsoft .NET Framework Version 4.7.03056

Installed Version: Community

Visual C++ 2019 00435-60000-00000-AA597 Microsoft Visual C++ 2019

Application Insights Tools for Visual Studio Package 9.1.00611.1 Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2019 16.2.290.48383 ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.2.290.48383 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.2.290.48383 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.2.290.48383 Azure Functions and Web Jobs Tools

C# Tools 3.2.0-beta4-19359-03+15b43b33901c88f68ef43f8314b5a2457716780d 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

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 0x10 - v2.9.20626.2

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 1.0 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.2.6 (4cfc7c3) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 5.2.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

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.61906.28070 Microsoft SQL Server Data Tools

TypeScript Tools 16.0.10627.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.2.0-beta4-19359-03+15b43b33901c88f68ef43f8314b5a2457716780d 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.4 for F# 4.6 16.2.0-beta.19321.1+a24d94ecf97d0d69d4fbe6b8b10cd1f97737fff4 Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

Xamarin 16.2.0.90 (d16-2@ba267630e) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 16.2.0.325 (remotes/origin/d16-2@f10cfbf83) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates 16.3.117 (59a59e8) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK 9.4.0.51 (d16-2/9fa7775) Xamarin.Android Reference Assemblies and MSBuild support. Mono: mono/mono/2019-02@e6f5369c2d2 Java.Interop: xamarin/java.interop/d16-2@d64ada5 LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-2@6f6c969

Xamarin.iOS and Xamarin.Mac SDK 12.14.0.110 (a8bcecc) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

sdebruyn commented 5 years ago

I tried reproducing this with the gist you mentioned, but I couldn't find anything about strict mode in my logs. Replacing the penalty with PenaltyDeath didn't kill the app either.

Version info:

=== Visual Studio Enterprise 2019 for Mac ===

Version 8.2.2 (build 44)
Installation UUID: a231de72-ce95-41c0-972a-92853d22e883
    GTK+ 2.24.23 (Raleigh theme)
    Xamarin.Mac 5.14.0.85 (d16-2-fix-mac-updates / 86973979)

    Package version: 600000319

=== Mono Framework MDK ===

Runtime:
    Mono 6.0.0.319 (2019-02/52203786470) (64-bit)
    Package version: 600000319

=== NuGet ===

Version: 5.1.0.6013

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Version: 2.1.12
SDK: /usr/local/share/dotnet/sdk/2.1.701/Sdks
SDK Version: 2.1.701
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.0.0/lib/mono/msbuild/Current/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.11
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 11.0 (14908.4)
Build 11M382q

=== Xamarin.Mac ===

Version: 5.99.2.40 (Visual Studio Enterprise)
Hash: d883febf
Branch: xcode11
Build date: 2019-08-06 08:33:41-0400

=== Xamarin.iOS ===

Version: 12.99.2.40 (Visual Studio Enterprise)
Hash: d883febf
Branch: xcode11
Build date: 2019-08-06 08:33:40-0400

=== Xamarin Designer ===

Version: 16.2.0.401
Hash: a8111869d
Branch: remotes/origin/d16-2-xcode11
Build date: 2019-08-05 20:44:10 UTC

=== Xamarin.Android ===

Version: 9.4.1.0 (Visual Studio Enterprise)
Commit: xamarin-android/d16-2/ebd65c9
Android SDK: /Users/sam/Library/Android/sdk
    Supported Android versions:
        7.1 (API level 25)
        8.0 (API level 26)
        8.1 (API level 27)

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 29.0.2
SDK Build Tools Version: 29.0.2

Build Information: 
Mono: mono/mono/2019-02@e6f5369c2d2
Java.Interop: xamarin/java.interop/d16-2@d64ada5
LibZipSharp: grendello/LibZipSharp/d16-2@caa0c74
LibZip: nih-at/libzip/rel-1-5-1@b95cf3f
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.27.1@8212a2d
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-2@6f6c969

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/sam/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 1.2.0.58
Hash: d03e3ea
Branch: remotes/origin/d16-2~1
Build date: 2019-08-05 20:08:02 UTC

=== Xamarin Inspector ===

Version: 1.4.3
Hash: db27525
Branch: 1.4-release
Build date: Mon, 09 Jul 2018 21:20:18 GMT
Client compatibility: 1

=== Build Information ===

Release ID: 802020044
Git revision: 2be0fd83c12d2bf1d60b2e5413d8517b8779bb74
Build date: 2019-08-07 07:47:32+00
Build branch: release-8.2-xcode11
Xamarin extensions: 559d23bf0f48ccb83b732417a122fc66e0a2640a

=== Operating System ===

Mac OS X 10.14.6
Darwin 18.7.0 Darwin Kernel Version 18.7.0
    Thu Jun 20 18:42:21 PDT 2019
    root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

NuGet Package Explorer 0.3.3
Mutatio 1.0.3
NuGet Package Management Extensions 0.19
Android Signature Tool 2.2.0
XAML Styler 1.1.3
MSBuild Editor 2.2.0