0

I am implementing Chromecast feature with CastCompanionLibrary-android for an Android video app. And I found this bug at the final test: I am not able to stop casting after reconnecting to wifi and recovering the same session.

To reproduce the bug:

  1. cast a video onto Chromecast first
  2. disconnect to wifi -> reconnect to wifi (the disconnection lasts for about 8 seconds in my case), the session seems to recovered successfully: the mini-controller is working and showing the updated information for the casting video, and I can pause/play current video with buttons on mini-controller, too.
  3. But if I click the cast icon and choose stop casting, although the icon button shows disconnected, the video is still playing on Chromecast.
  4. A weird thing is, after session recovered, if I first click pause/play button on MiniController, then the stop casting works well. But without using the MiniController, the stop casting fails.

I set mCastManager.reconnectSessionIfPossible(Constants.CC_RECONNECT_TIMEOUT) at MainActivity's onCreate(); And I tried to enable/disable enabledWifiReconnection(), enableAutoReconnect() in CastConfiguration, but this bug always appears.

I didn't see this bug on the CCL's sample app so far though.

logs after wifi interruption is attached as below.

D/ccl_BaseCastManager: [v2.8.3] Successfully removed the existing BaseCastConsumer listener com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerFragment$MyCastConsumer@1e5000da
D/ccl_BaseCastManager: [v2.8.3] UI is no longer visible
D/ccl_BaseCastManager: [v2.8.3] Successfully added the new BaseCastConsumer listener com.sample.MainActivity$6@259d2d91
D/ccl_VideoCastManager: [v2.8.3] Successfully added the new CastConsumer listener com.sample.MainActivity$6@259d2d91
D/ccl_BaseCastManager: [v2.8.3] UI is visible
D/ccl_BaseCastManager: [v2.8.3] onUiVisibilityChanged() addCallback called
D/ccl_BaseCastManager: [v2.8.3] reconnectSessionIfPossible(10, null)
D/ccl_VideoCastControlle: [v2.8.3] onDestroy()
D/ccl_VideoCastControlle: [v2.8.3] Stopped TrickPlay Timer
D/ccl_BaseCastManager: [v2.8.3] onConnectionSuspended() was called with cause: 2
D/ccl_BaseCastManager: [v2.8.3] UI is no longer visible
D/ccl_BaseCastManager: [v2.8.3] Successfully removed the existing BaseCastConsumer listener com.sample.MainActivity$6@259d2d91
D/ccl_BaseCastManager: [v2.8.3] onUiVisibilityChanged() removeCallback called
D/ccl_BaseCastManager: [v2.8.3] Successfully added the new BaseCastConsumer listener com.sample.MainActivity$6@259d2d91
D/ccl_VideoCastManager: [v2.8.3] Successfully added the new CastConsumer listener com.sample.MainActivity$6@259d2d91
D/ccl_BaseCastManager: [v2.8.3] UI is visible
D/ccl_BaseCastManager: [v2.8.3] onUiVisibilityChanged() addCallback called
D/ccl_BaseCastManager: [v2.8.3] reconnectSessionIfPossible(10, null)
D/ccl_BaseCastManager: [v2.8.3] Found session info in the preferences, so proceed with an attempt to reconnect if possible
D/ccl_BaseCastManager: [v2.8.3] reconnectSessionIfPossible() Retrieved from preferences: sessionId=1FEB6B9C-5044-48CA-81DA-C5A9A0E5BEF7, routeId=com.google.android.gms/.cast.media.CastMediaRouteProviderService:2e6c7705d9c05354634e102f627ef1e2
D/ccl_BaseCastManager: [v2.8.3] trying to acquire Cast Client for "Chromecast0315" (2e6c7705d9c05354634e102f627ef1e2)
32284-32459/com.sample.mobile.sample D/ccl_BaseCastManager: [v2.8.3] Reconnection: Attempt 1
D/ccl_VideoCastManager: [v2.8.3] onVolumeChanged() reached
E/ccl_VideoCastManager: [v2.8.3] Failed to get volume
    com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException
     at com.google.android.libraries.cast.companionlibrary.cast.BaseCastManager.checkConnectivity(BaseCastManager.java:1117)
     at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.getVolume(VideoCastManager.java:631)
     at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.onVolumeChanged(VideoCastManager.java:857)
     at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager.access$1300(VideoCastManager.java:130)
     at com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager$CastListener.onVolumeChanged(VideoCastManager.java:2644)
     at com.google.android.gms.cast.internal.zze.zza(Unknown Source)
     at com.google.android.gms.cast.internal.zze.zza(Unknown Source)
     at com.google.android.gms.cast.internal.zze$zzb$2.run(Unknown Source)
     at android.os.Handler.handleCallback(Handler.java:739)
     at android.os.Handler.dispatchMessage(Handler.java:95)
     at android.os.Looper.loop(Looper.java:135)
     at android.app.ActivityThread.main(ActivityThread.java:5297)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
D/ccl_BaseCastManager: [v2.8.3] onConnected() reached with prior suspension: true
D/ccl_VideoCastManager: [v2.8.3] Registering MediaChannel namespace
32284-32459/com.sample.mobile.sample D/ccl_BaseCastManager: [v2.8.3] Reconnection: Attempt 2
32284-32459/com.sample.mobile.sample D/ccl_BaseCastManager: [v2.8.3] Reconnection: Attempt 3
D/ccl_CastMediaRouterCal: [v2.8.3] onRouteUnselected: route=MediaRouter.RouteInfo{ uniqueId=com.google.android.gms/.cast.media.CastMediaRouteProviderService:2e6c7705d9c05354634e102f627ef1e2, name=Chromecast0315, description=Ready to play, iconUri=null, enabled=true, connecting=false, connectionState=0, canDisconnect=false, playbackType=1, playbackStream=-1, deviceType=0, volumeHandling=1, volume=20, volumeMax=20, presentationDisplayId=-1, extras=Bundle[mParcelledData.dataSize=636], settingsIntent=null, providerPackageName=com.google.android.gms }
D/ccl_BaseCastManager: [v2.8.3] disconnectDevice(true,false)
D/ccl_BaseCastManager: [v2.8.3] disconnectDevice() Disconnect Reason: Intentional disconnect
D/ccl_BaseCastManager: [v2.8.3] mConnectionSuspended: false
D/ccl_BaseCastManager: [v2.8.3] clearPersistedConnectionInfo(): Clearing persisted data for 0
D/ccl_VideoCastManager: [v2.8.3] trying to detach media channel
D/ccl_BaseCastManager: [v2.8.3] Trying to disconnect
D/ccl_BaseCastManager: [v2.8.3] onDisconnected() reached
D/ccl_VideoCastManager: [v2.8.3] updateMiniControllersVisibility() reached with visibility: false
D/ccl_VideoCastManager: [v2.8.3] clearMediaSession()

Anybody encounters similar issues with the session reconnection with wifi? Or anyone has a hint what my problem could be? Much appreciate for any hints!

rekire
  • 47,260
  • 30
  • 167
  • 264
  • What receiver are you using, is it your own (custom receiver), Styled Receiver or the Default Receiver? – Ali Naddaf Apr 27 '16 at 02:47
  • Yes we are using a custom receiver. It's not written by me so I didn't realize that. Do you think it's a problem for receiver side? I will look into it and update more info. Thank you – user3335072 May 02 '16 at 22:38
  • In 3, when disconnect doesn't stop the cast session (assuming you are the only connected sender), you need to look at the logs on the receiver (console logs) and see what exactly is happening when you send the disconnect message. Since it is a custom receiver, you should be able to look at the logs, assuming that you can register your device under that app id. – Ali Naddaf May 03 '16 at 07:42

0 Answers0