Skip to content

Members of a singleTop activity in background are finalized #2072

@georgivzh

Description

@georgivzh

Steps to Reproduce

  1. Create an activity with a singleTop launch mode and add a class member of type ObservableCollection or LruCache.

  2. Create a second activity with a parent the first activity.

  3. Run the app and from the first activity (which is the main activity) start the second activity.

  4. Now do some resource consumption operation as loading a bitmap.

The result is JavaFinalize() is called on the member of the first activity while the second activity is displayed and the first is in background. This is not acceptable! The instance of the first activity is still alive, but some members are disposed (Java.Lang.Object Handle becomes null). When I return back to the first activity that member is already disposed (OnCreate is not called because of the singleTop mode).

Expected Behavior

All members of the first activity should be alive.

Actual Behavior

Some of the members of the first activity are disposed.

Version Information

Xamarin Android SDK 8.3.3.2.

Reproduced on a real device (LG G4C) running Android API 23.

Visual Studio Community version 15.7.5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App RuntimeIssues in `libmonodroid.so`.possibly-staleIssues that are potentially no longer relevant.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions