Skip to content
This repository was archived by the owner on Nov 1, 2022. It is now read-only.
This repository was archived by the owner on Nov 1, 2022. It is now read-only.

Memory leak in consumeFlow if fragment activity recreated before channel is created #9017

@csadilek

Description

@csadilek

Unlike consumeFrom, consumeFlow creates the SubscriptionLifecycleBinding asynchronously in the ProducerScope (a suspend lambda) passed to channelFlow: https://github.com/mozilla-mobile/android-components/blob/master/components/lib/state/src/main/java/mozilla/components/lib/state/ext/StoreExtensions.kt#L155

By the time this code runs, the fragment can already be in a different state e.g. in Fenix, which recreates the activity when switching between private and normal tabs, the original fragment's activity is already null at this point. We still register a subscription and a SubscriptionLifecycleBinding, but we never unregister because we won't observe lifecycle changes for this fragment, and therefore leak the fragment via the subscription.

This is one of the leaks triggered by switching between normal and private mode (not described in the ticket but same STR): mozilla-mobile/fenix#13785

┆Issue is synchronized with this Jira Task

Metadata

Metadata

Assignees

Labels

<state>Component: browser-state🐞 bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions