Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecyclerBinder can leak OnPreDrawListener if unmount is called after view has been detached #770

Open
1 task
PicardyThird opened this issue Feb 18, 2021 · 0 comments

Comments

@PicardyThird
Copy link

PicardyThird commented Feb 18, 2021

Version

0.39.0

Issues and Steps to Reproduce

RecyclerBinder mount and unmount assume that the same ViewTreeObserver is associated with the RecyclerView when that may not be the case.

There is one ViewTreeObserver that is active while the view is attached to the window, and another "floating" ViewTreeObserver that is active when the view is detached from the window.

See implementation of View#getViewTreeObserver for reference.

Using RecyclerBinder from a Fragment:

  1. Call RecyclerBinder#mount from Fragment's onCreateView lifecycle callback
  2. Call RecyclerBinder#unmount from Fragment's onDestroyView lifecycle callback

Expected Behavior

When RecyclerBinder#unmount is called, expected that when unmount calls unregisterDrawListener that the OnPreDrawListener is removed from the ViewTreeObserver.

Actual Behavior

When RecyclerBinder#unmount is called, the OnPreDrawListener is not removed when unregisterDrawListener is called because the ViewTreeObserver returned is the one representing the "floating" detached view state.

This leaks the OnPreDrawListener.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant