No notifications on Rx GC
Mecharyry opened this issue · 1 comments
Problem
MerlinAction
registers Connectable
, Disconnectable
and Bindable
s through anonymous classes. Under the hood these Registerable
are stored in a List<WeakRegisterableReference>
so when the method terminates these Registerable
s are no longer strongly referenced making them eligible for GarbageCollection
. Practically, this means that clients of the apps will not be able to respond to network status changes because they never know about them.
The WeakRegisterableReference
is only an issue for the Rx pipeline because users will likely bind the Registerable
s directly to an activity keeping a StrongReference
.
Potential Solution
It seems we have two potential solutions.
One: Use Strong references for the Registerer
, it seems that WeakReference
was used to mitigate the risk of memory leaks should a client forget to unbind
.
Two: We create a local stash for the Connectable
, Disconnectable
and Bindable
in MerlinAction
which will keep a permanent StrongReference
until everything is torn down.
Steps to reproduce
- Open either of the RxDemos
- Observe initial network status
- Trigger a GC in AndroidStudio
- Enter airplane mode
Expected: Network status disconnected observed
Actual: No network status updates,
Impact
Clients will not receive notifications of changes in connectivity when using the Rx pipeline for Merlin based on the GC mechanism used on different devices.
Paired with
Thank you to @niltsiar for getting in contact with the issue and further discussion.
Addressed in v1.0.1.