youtube / api-samples

Code samples for YouTube APIs, including the YouTube Data API, YouTube Analytics API, and YouTube Live Streaming API. The repo contains language-specific directories that contain the samples.
5.49k stars 2.98k forks source link

[YouTubeAndroidPlayerAPI] YouTubeService has leaked IntentReceiver #166

Open guilhermesgb opened 6 years ago

guilhermesgb commented 6 years ago

I'm seeing the following issue happening sometimes:

E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver vsl@25bf10e that was originally registered here. Are you missing a call to unregisterReceiver()?
                  android.app.IntentReceiverLeaked: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver vsl@25bf10e that was originally registered here. Are you missing a call to unregisterReceiver()?
                      at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1351)
                      at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1132)
                      at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1421)
                      at android.app.ContextImpl.registerReceiver(ContextImpl.java:1394)
                      at android.app.ContextImpl.registerReceiver(ContextImpl.java:1382)
                      at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:609)
                      at vsj.<init>(SourceFile:21)
                      at vsq.get(SourceFile:9)
                      at wzg.get(SourceFile:31)
                      at adzu.get(SourceFile:10)
                      at hog.a(SourceFile:26)
                      at hpb.a(SourceFile:881)
                      at hnz.<init>(SourceFile:13)
                      at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(SourceFile:60)
                      at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerFactoryService$1.run(SourceFile:10)
                      at android.os.Handler.handleCallback(Handler.java:790)
                      at android.os.Handler.dispatchMessage(Handler.java:99)
                      at android.os.Looper.loop(Looper.java:164)
                      at android.app.ActivityThread.main(ActivityThread.java:6494)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver vsi@d2cf74b that was originally registered here. Are you missing a call to unregisterReceiver()?
                  android.app.IntentReceiverLeaked: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver vsi@d2cf74b that was originally registered here. Are you missing a call to unregisterReceiver()?
                      at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1351)
                      at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1132)
                      at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1421)
                      at android.app.ContextImpl.registerReceiver(ContextImpl.java:1394)
                      at android.app.ContextImpl.registerReceiver(ContextImpl.java:1382)
                      at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:609)
                      at wyy.<init>(SourceFile:53)
                      at wzg.get(SourceFile:32)
                      at adzu.get(SourceFile:10)
                      at hog.a(SourceFile:26)
                      at hpb.a(SourceFile:881)
                      at hnz.<init>(SourceFile:13)
                      at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(SourceFile:60)
                      at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerFactoryService$1.run(SourceFile:10)
                      at android.os.Handler.handleCallback(Handler.java:790)
                      at android.os.Handler.dispatchMessage(Handler.java:99)
                      at android.os.Looper.loop(Looper.java:164)
                      at android.app.ActivityThread.main(ActivityThread.java:6494)
                      at java.lang.reflect.Method.invoke(Native Method)
                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Even though this is happening under the hood, it doesn't seem to impact the player, as I can still play videos normally. I've seen just another person reporting this on StackOverflow almost two years ago, so I wonder if this is my fault somehow?...

I am paying close attention to the context lifecycle (the parent context where my player is located) which is actually a Fragment containing a ViewPager, with the first page being the only one to contain my YouTubePlayerSupportFragment. I'm initializing and releasing the player in the appropriate places:

    @Override
    public void onStart() {
        super.onStart();
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
            initPlayer();
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if ((Build.VERSION.SDK_INT <= Build.VERSION_CODES.M)) {
            if (player == null) {
                initPlayer();
            }
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
            if (player != null) {
                player.release();
                player = null;
            }
        }
    }

    @Override
    public void onStop() {
        super.onStop();
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
            if (player != null) {
                player.release();
                player = null;
            }
        }
    }

So any help on mitigating this issue will be very much appreciated.

aman-ar commented 6 years ago

Getting the same issue with my app

gonzalonm commented 6 years ago

Same thing here..

BMarton commented 5 years ago

Did you guys find out anything? I'm getting the same error.

ikram0788 commented 5 years ago

I am also getting the same error

RomanSytnyk commented 5 years ago

Getting the same issue

MrAndrew commented 5 years ago

Over a year old, any news or updates on this?

payne-miller-ck commented 4 years ago

Any updates on this issue? I am experiencing the same issue within an app I am working on. For my particular instance, it only occurs on a Google Pixel (1st Generation) running Android 10. This crash happens within a Google Chrome browser that has no other tabs open, while running no other apps on the phone. Any information would be greatly appreciated!

2019-11-25 13:58:54.358 14281-14281/? E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver ahop@1326d50 that was originally registered here. Are you missing a call to unregisterReceiver()?
    android.app.IntentReceiverLeaked: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver ahop@1326d50 that was originally registered here. Are you missing a call to unregisterReceiver()?
        at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1588)
        at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1368)
        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1515)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1488)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1476)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
        at ajiv.<init>(PG:44)
        at ajke.get(PG:35)
        at bdcx.get(PG:6)
        at bdcw.get(PG:3)
        at mwx.G(PG:155)
        at ahng.a(PG:5)
        at ahng.get(PG:4)
        at bdcx.get(PG:6)
        at mwz.a(PG:3)
        at muc.<init>(PG:16)
        at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(PG:43)
        at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerFactoryService$1.run(PG:2)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
2019-11-25 13:58:54.360 14281-14281/? E/ActivityThread: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver ahor@92cc8b4 that was originally registered here. Are you missing a call to unregisterReceiver()?
    android.app.IntentReceiverLeaked: Service com.google.android.youtube.api.service.YouTubeService has leaked IntentReceiver ahor@92cc8b4 that was originally registered here. Are you missing a call to unregisterReceiver()?
        at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1588)
        at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1368)
        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1515)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1488)
        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1476)
        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:627)
        at ahor.a(PG:12)
        at ahow.<init>(PG:11)
        at ahox.a(PG:9)
        at ajke.get(PG:33)
        at bdcx.get(PG:6)
        at bdcw.get(PG:3)
        at mwx.G(PG:155)
        at ahng.a(PG:5)
        at ahng.get(PG:4)
        at bdcx.get(PG:6)
        at mwz.a(PG:3)
        at muc.<init>(PG:16)
        at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerService.<init>(PG:43)
        at com.google.android.apps.youtube.embeddedplayer.service.service.jar.ApiPlayerFactoryService$1.run(PG:2)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
MatanKoby commented 4 years ago

Hi, I see this issue as well and would love a fix. Is the Youtube SDK for Android still maintained and given attention to by Youtube?