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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash using tooltip in adapter #93

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

eduardbosch
Copy link

Hi to all! 馃帀

As commented on this issue #28, using tooltips in adapters can cause NullPointerException when the adapter requests an update.

The problem is that when the adapter updates, the Tooltip might be removed if the adapter removes the Tooltip anchor from the layout. If this process happens in the middle of a FrameLayout.onLayout, that causes the onLayout to iterate on null objects.

By delaying the Tooltip remove from its parent, this problem is solved because we avoid deleting views in the middle of a layout request.

Crash example

  1. The layout is requested. Suppose that there are 4 children.
    https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/FrameLayout.java#265
  2. The adapter updates its data in the middle of the layout request https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/FrameLayout.java#323
  3. If during point 2 the Tooltip anchor is removed from the layout, the Tooltip is also removed from the layout. In that case, the children of the layout are not 4 anymore because a Tooltip has been removed. Suppose that now we have 3 children only.
  4. The FrameLayout continue iterating in 4 objects, but one of them is null and that causes this line to crash:
    https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/widget/FrameLayout.java#275

# Conflicts:
#	app/build.gradle
#	build.gradle
#	gradle.properties
#	library/build.gradle
#	library/src/main/java/it/sephiroth/android/library/tooltip/Tooltip.java
@eduardbosch eduardbosch changed the base branch from master to develop December 20, 2018 12:09
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

Successfully merging this pull request may close these issues.

None yet

1 participant