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

EditText Blink causes memory leak in AlertDialog and DialogFragment #297

Closed
Yky opened this issue Oct 4, 2015 · 15 comments
Closed

EditText Blink causes memory leak in AlertDialog and DialogFragment #297

Yky opened this issue Oct 4, 2015 · 15 comments

Comments

@Yky
Copy link
Contributor

Yky commented Oct 4, 2015

See AOSP issue 188551: https://code.google.com/p/android/issues/detail?id=188551

Can be avoided by calling setCursorVisible(false) in the dismiss() method of the Dialog.

Yky pushed a commit to Yky/leakcanary that referenced this issue Oct 4, 2015
Yky pushed a commit to Yky/leakcanary that referenced this issue Oct 4, 2015
Yky pushed a commit to Yky/leakcanary that referenced this issue Oct 4, 2015
Yky pushed a commit to Yky/leakcanary that referenced this issue Oct 4, 2015
@Yky
Copy link
Contributor Author

Yky commented Oct 4, 2015

Added pull request for ignore of this AOSP bug.

@hidroh
Copy link

hidroh commented Oct 5, 2015

@Yky you mean setCursorVisible(false)?

@Yky
Copy link
Contributor Author

Yky commented Oct 6, 2015

@hidroh Yes, I corrected my comment above.

@Yky
Copy link
Contributor Author

Yky commented Oct 17, 2015

This leak is now confirmed by Google and has been fixed in Marshmallow.

@pyricau
Copy link
Member

pyricau commented Jan 4, 2016

PR mentioned above: #298

@pyricau pyricau added this to the 1.4 milestone Jan 4, 2016
@pyricau pyricau removed this from the 1.4 milestone Jan 8, 2016
Yky pushed a commit to Yky/leakcanary that referenced this issue Feb 10, 2016
Yky added a commit to Yky/leakcanary that referenced this issue Feb 21, 2016
jrodbx added a commit that referenced this issue Mar 20, 2016
ignore leakcanary issue #297; AOSP issue #188551
@Yky
Copy link
Contributor Author

Yky commented Apr 5, 2016

@pyricau I think this can be closed as the commit is included in 1.4-beta2

@jrodbx
Copy link
Collaborator

jrodbx commented Apr 6, 2016

@Yky thanks!

@jrodbx jrodbx closed this as completed Apr 6, 2016
@knezmilos13
Copy link

I am using 1.4-beta2, on 4.1.1 it says: "This can be fixed manually by calling setCursorEnabled(false) ..." while it should say setCursorVisible(false), right?

pyricau added a commit that referenced this issue Sep 18, 2016
@pyricau
Copy link
Member

pyricau commented Sep 18, 2016

Thx @knezmilos13 , fixed.

pyricau added a commit that referenced this issue Sep 19, 2016
Pengchengxiang pushed a commit to XLibrarys/leakcanary that referenced this issue Jan 2, 2017
Pengchengxiang pushed a commit to XLibrarys/leakcanary that referenced this issue Jan 2, 2017
ignore leakcanary issue square#297; AOSP issue #188551
Pengchengxiang pushed a commit to XLibrarys/leakcanary that referenced this issue Jan 2, 2017
Pengchengxiang pushed a commit to XLibrarys/leakcanary that referenced this issue Jan 2, 2017
@realdadfish
Copy link

Sorry for reviving this from the death, but I figured that the exact same leak occurs also on a Samsung Device with 5.0.1 installed, but without the need of having a DialogFragment present. A simple EditText with a blinking cursor was enough to trigger it for me.

I tried the solution and called setCursorVisible(false) in onDetachFromWindow() from the surrounding compound view, but this did not help. Guess we just have to wait until 5.x finally dies.

@Yky
Copy link
Contributor Author

Yky commented Dec 19, 2017

@realdeadfish I would try moving the setCursorVisible(false) to a different lifecycle method that is always called before your Activity is destroyed. I don't know the details of your leak but you could try onPause().

@yoavgray
Copy link

I'm seeing this as well on a Samsung S7 with Android 7 running on it. LeakCanary says that a Thread is referencing InputConnectionWrapper.mTarget about ~15 times, and then it leaks a Dialogfragment with the EditText

@madim
Copy link

madim commented Mar 29, 2018

@realdeadfish Did you fix that?

@indiandragon
Copy link

Guys, the only solution that worked for me was to Override InputConnection to return null as suggested by @aslakjo in SO - https://stackoverflow.com/a/18697200

I cannot believe this issue is still not addressed in android.

@adsonafonso
Copy link

adsonafonso commented Nov 1, 2019

I'm using a Pixel 2, Android 10 and I ran into this

├─ android.net.ConnectivityThread
│ Leaking: UNKNOWN
│ Thread name: 'ConnectivityThread'
│ GC Root: Java local variable
│ ↓ thread ConnectivityThread.
│ ~~~~~~~~~~~~
├─ android.os.Message
│ Leaking: UNKNOWN
│ ↓ Message.obj
│ ~~~
╰→ co.optimal.android.util.ChoosePhotoFragment
​ Leaking: YES (Fragment#mFragmentManager is null and ObjectWatcher was watching this)
​ key = 745f218b-4145-409b-99e7-f84ef01d1bc2
​ watchDurationMillis = 39206
​ retainedDurationMillis = 34205
, retainedHeapByteSize=504845, pattern=instance field android.os.Message#obj...

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

No branches or pull requests

10 participants