Fixed
Status Update
Comments
fr...@gmail.com <fr...@gmail.com> #2
MemoryLeak doesn't happen with MediaController and MediaSession in a same situation.
fr...@gmail.com <fr...@gmail.com> #3
In support library version 25.0.1 this leak doesn't happen using MediaControllerCompat and MediaSessionCompat.
al...@gmail.com <al...@gmail.com> #4
Do not know if it is related, but some users have reported random auto casting in my app with mediarouter-v7:25.1.0. Reverting to 25.0.1 fixed the issue.
sm...@gmail.com <sm...@gmail.com> #5
This is a pretty serious leak and shouldn't be "small" priority. Essentially if you use a MediaController in any activity using 25.1.0, you will leak that activity if you follow the guidelines for setting up a media browser.
Workaround is to use 25.0.1 or possibly passing an application context to the constructor of the MediaControllerCompat... (although I haven't verified that is without side effects across all releases).
Workaround is to use 25.0.1 or possibly passing an application context to the constructor of the MediaControllerCompat... (although I haven't verified that is without side effects across all releases).
am...@google.com <am...@google.com> #6
Hi
Provide below info requested for further analysis
I have just tried by using the leakcanary app, but it did not show any leaks with respect to this example reported here
So provide clear steps to reproduce the issue
If you are using the leakcanary app, provide it's apk too
Provide whole bugreport aslo
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Provide screenrecord for more claritry
Screen Record of the Issue
Please capture screen record or video of the issue using following steps:
adb shell screenrecord /sdcard/video.mp4
Subsequently use following command to pull the recorded file:
adb pull /sdcard/video.mp4
Attach the file to this issue.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
Provide below info requested for further analysis
I have just tried by using the leakcanary app, but it did not show any leaks with respect to this example reported here
So provide clear steps to reproduce the issue
If you are using the leakcanary app, provide it's apk too
Provide whole bugreport aslo
Android bug report:
After reproducing the issue, navigate to developer settings, ensure ‘USB debugging’ is enabled, then enable ‘Bug report shortcut’. To take bug report, hold the power button and select the ‘Take bug report’ option.
Provide screenrecord for more claritry
Screen Record of the Issue
Please capture screen record or video of the issue using following steps:
adb shell screenrecord /sdcard/video.mp4
Subsequently use following command to pull the recorded file:
adb pull /sdcard/video.mp4
Attach the file to this issue.
Note: Please upload the files to google drive and share the folder to android-bugreport@google.com, then share the link here.
fr...@gmail.com <fr...@gmail.com> #7
[Comment deleted]
fr...@gmail.com <fr...@gmail.com> #8
Hello
Steps to reproduce the issue:
1- Tap "Another Activity" button.
2- Back to "MediaControllerCompatReproCase" activity.
3- Just it.
I am using leakcanary (1.5 version).
Link to log and video:https://drive.google.com/drive/folders/0B_oWUTbCU2nhQVJzc04wQ3ozUnM?usp=sharing
Note: In according to create the log and video was used the following configuration:
Library used (support-v4):
Version used: 25.1.0
Devices/Android versions reproduced on:
Nexus 4 API 23
Thanks
Steps to reproduce the issue:
1- Tap "Another Activity" button.
2- Back to "MediaControllerCompatReproCase" activity.
3- Just it.
I am using leakcanary (1.5 version).
Link to log and video:
Note: In according to create the log and video was used the following configuration:
Library used (support-v4):
Version used: 25.1.0
Devices/Android versions reproduced on:
Nexus 4 API 23
Thanks
am...@google.com <am...@google.com> #9
Hi,
Please share whole bugreport
So, to reproduce the issue, I should have the leak canary app running in background and follow the video given here , is it?
Please share the leakcanary apk too
Please share whole bugreport
So, to reproduce the issue, I should have the leak canary app running in background and follow the video given here , is it?
Please share the leakcanary apk too
sm...@gmail.com <sm...@gmail.com> #10
Leak canary doesn't require an APK. See https://github.com/square/leakcanary for how it works if you are unfamiliar.
You should also see the activity leak using Android Studio if you take a memory dump after visiting the AnotherActivity a few times and run activity leak detection.
However, I'm not sure why you need the reproduction because the ResultReceiver added in 25.1.0 is clearly the cause of the leak. The anonymous class holds an implicit reference to the MediaController. The media controller holds a reference to the context (activity) used to create it.
A better technique would be to create a static inner class of the ResultReceiver. When it is constructed the ResultReceiver should hold a WeakReference to the MediaController. This is because the ResultReceiver may outlive the object it was created with. Obviously onReceiveResult will have to see if the WeakReference still references the MediaController. If not, shouldn't do anything.
You should also see the activity leak using Android Studio if you take a memory dump after visiting the AnotherActivity a few times and run activity leak detection.
However, I'm not sure why you need the reproduction because the ResultReceiver added in 25.1.0 is clearly the cause of the leak. The anonymous class holds an implicit reference to the MediaController. The media controller holds a reference to the context (activity) used to create it.
A better technique would be to create a static inner class of the ResultReceiver. When it is constructed the ResultReceiver should hold a WeakReference to the MediaController. This is because the ResultReceiver may outlive the object it was created with. Obviously onReceiveResult will have to see if the WeakReference still references the MediaController. If not, shouldn't do anything.
il...@google.com <il...@google.com>
al...@gmail.com <al...@gmail.com> #11
There is still auto casting issue in com.android.support:mediarouter-v7:25.1.1. Reverting to 25.0.1 fixed the issue.
pe...@gmail.com <pe...@gmail.com> #12
I met the same problem when i chage the support from 25.0.1 to 25.1.0,LeakCanary warn the same message,so i change my code from:
mMdeMediaControllerCompat = new MediaControllerCompat(xxxActivity.this, mMediaBrowserCompat.getSessionToken());
to
mMdeMediaControllerCompat = new MediaControllerCompat(getApplicationContext(), mMediaBrowserCompat.getSessionToken());
After then,it is works,and LeakCanary won't warn that leak since then!
mMdeMediaControllerCompat = new MediaControllerCompat(xxxActivity.this, mMediaBrowserCompat.getSessionToken());
to
mMdeMediaControllerCompat = new MediaControllerCompat(getApplicationContext(), mMediaBrowserCompat.getSessionToken());
After then,it is works,and LeakCanary won't warn that leak since then!
dn...@google.com <dn...@google.com> #13
Issue is fixed and released in 25.2.0 support library.
Description
Version used: 25.1.0
Devices/Android versions reproduced on:
Nexus 4 Nougat API 25
The issues happens when the MediaControllerCompat is created with the token of the a MediaSessionCompat which has its lifecycle bind to the application.
Here is the LeakCanary log:
In br.com.me.mediacontrollercompatreprocase:1.0:1.
* br.com.me.mediacontrollercompatreprocase.AnotherActivity has leaked:
* GC ROOT android.os.ResultReceiver$MyResultReceiver.this$0
* references android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi21$1.this$0 (anonymous subclass of android.os.ResultReceiver)
* references android.support.v4.media.session.MediaControllerCompat$MediaControllerImplApi24.mControllerObj
* references android.media.session.MediaController.mContext
* leaks br.com.me.mediacontrollercompatreprocase.AnotherActivity instance
* Retaining: 48 KB.
* Reference Key: c72cb728-7e92-4fce-959a-b2a856ea7af6
* Device: unknown Android Android SDK built for x86_64 sdk_google_phone_x86_64
* Android Version: 7.1 API: 25 LeakCanary: 1.5 00f37f5
* Durations: watch=5013ms, gc=112ms, heap dump=3237ms, analysis=18682ms
For more details, you could use the following sample to reproduce it.