ConnectSDK / Connect-SDK-Android

Android source project for Connect SDK
Apache License 2.0
308 stars 130 forks source link

What do I do when only DIAL is available for a Chromecast device? #302

Open casolorz opened 9 years ago

casolorz commented 9 years ago

I'm rolling out my update in which I moved from the CastCompanionLibrary to ConnectSDK and I've started getting bad reviews every day because the Chromecast is missing from the picker dialog. Only one user has actually emailed me about it and I had her try the ConnectSDK Sampler and her 3 Chromecast devices only show as DIAL which is probably why they don't show up on my app. I had her reboot her Chromecast, phone and wifi and still that didn't help. What can I do to help her troubleshoot/fix this issue? and more importantly what do I need to collect from her in terms of logs to see if there is a bug in ConnectSDK that needs to be fixed?

Thanks.

oleksii-frolov commented 9 years ago

One of the reasons can be that master branch uses old play-services-cast library. CastCompanion uses the latest, so dependencies should look like this:

compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:mediarouter-v7:22.2.1'
compile 'com.google.android.gms:play-services-cast:7.8.0'

We updated dependencies in dev branch. Please try to check the app with these dependencies if it's possible.

casolorz commented 9 years ago

I did that by hand before releasing my app but I haven't done that for the ConnectSDK Helper so I'll see if it makes a difference there.

casolorz commented 9 years ago

One other thing I forgot to mention, my old version was released in June so it had an older CastCompanion library, it was released before Google Play Services 7.5 actually.

casolorz commented 9 years ago

Built a new Sampler apk today with the latest out of dev and the user reports that her Chromecast devices are still only showing as DIAL. What else can I have her do to test? Also I sent her the old apk of my app that uses the CastCompanion library and she said as soon as she installed the old apk then my app started showing the Chromecast again.

oleksii-frolov commented 9 years ago

Can you try ConnectSDK v1.4.4? We changed Chromecast discovery in 1.5.0.

casolorz commented 9 years ago

She just tried it with 1.4.4 and had the same issue.

This is an interesting case because every time this has happened to me I've always been able to get it to work either by waiting a while or rebooting everything, but she has been at this for over a day now and multiple reboots.

casolorz commented 9 years ago

So I added a lot of log lines to the discovery manager and had this one user run it. I'm still going over all the calls but I don't see a single call to any of the methods inside MediaRouterCallback. That seems odd, right?

casolorz commented 9 years ago

I figured it might be good to update you on this. I've been doing a lot of testing with two users who want to help, and I've written my own test based on your discovery code to do the testing. Anyways, I've reported the issue to Google at https://code.google.com/p/google-cast-sdk/issues/detail?id=642

The only way I've gotten it to work for them is by using MediaRouter.CALLBACK_FLAG_FORCE_DISCOVERY but that certainly doesn't seem like a good solution. I'll report back when Google answers.

jamescahall commented 8 years ago

Chromecast was working for us for many months and then recently is only showing up as a DIAL service like mentioned above. This is happening on all the devices we are testing including Galaxy S6 with Android 5. This is a critical item as we are starting to get a lot of complaints about Chromecast not working. The iOS SDK works fine. As it shows up as DIAL, it doesn't work.

mdltorriente commented 8 years ago

I'm experiencing the same issue. When I launch my app for the first time (or force stop then restart) I can see both Chromecast and DIAL services. Once the app is put in the background and then resumed, the Chromecast service drops. The workaround you mentioned previously using the MediaRouter.CALLBACK_FLAG_FORCE_DISCOVERY flag doesn't work for me.

BTW The iOS SDK is working fine for me too.

casolorz commented 8 years ago

I stopped using ConnectSDK for Chromecast connectivity a while back. Discovery issues were killing me reviews wise and Google told me they wouldn't help me unless I used the cast companion library.

jamescahall commented 8 years ago

Chromecast is the most widely used casting device so it's critical that this works. I don't understand how this has been an open issue for so many months.

casolorz commented 8 years ago

It is a really hard issue to troubleshoot and fix. I could never reliably reproduce it on my end but I had a handful of users that could reproduce it. I had other issues with ConnectSDK and how it handled starting the Chromecast webapp so for me it was just easier to move away from it since Chromecast was and continues to be my most used streaming device. I still use it for connectivity to other devices and will continue to unless development of ConnectSDK stops.

jamescahall commented 8 years ago

Ok. So the issue is that "onRouteAdded" is not getting called (except for like 1% of the time it seems). Instead "onRouteChanged" is being called. In this function, it checks to see if it's a new found service or not. There was no case to assume onRouteAdded was never called.

Just add this: if (isNew) { foundService = new ServiceDescription(CastService.ID, uuid, castDevice.getIpAddress().getHostAddress()); foundService.setFriendlyName(castDevice.getFriendlyName()); foundService.setServiceID(CastService.ID); listUpdateFlag = true; isNew = false; }

above the if (!isNew) in the CastDiscoveryProvider and all should be solved.

ghost commented 8 years ago

@jamescahall Thank you so much for this solution! You have made my day! :)

krishna415741 commented 1 year ago

Ok. So the issue is that "onRouteAdded" is not getting called (except for like 1% of the time it seems). Instead "onRouteChanged" is being called. In this function, it checks to see if it's a new found service or not. There was no case to assume onRouteAdded was never called.

Just add this: if (isNew) { foundService = new ServiceDescription(CastService.ID, uuid, castDevice.getIpAddress().getHostAddress()); foundService.setFriendlyName(castDevice.getFriendlyName()); foundService.setServiceID(CastService.ID); listUpdateFlag = true; isNew = false; }

above the if (!isNew) in the CastDiscoveryProvider and all should be solved.

Hi

Can you provide more info on where do I need to add these lines. Thank you

jamescahall commented 1 year ago

CastDiscoveryProvider above:

Line 241 if (!isNew) {

` @Override public void onRouteChanged(MediaRouter router, RouteInfo route) { super.onRouteChanged(router, route);

        CastDevice castDevice = CastDevice.getFromBundle(route.getExtras());
        String uuid = castDevice.getDeviceId();

        ServiceDescription foundService = foundServices.get(uuid);

        boolean isNew = foundService == null;
        boolean listUpdateFlag = false;

        if (isNew) {
            foundService = new ServiceDescription(CastService.ID, uuid,
                    castDevice.getIpAddress().getHostAddress());
            foundService.setFriendlyName(castDevice.getFriendlyName());
            foundService.setServiceID(CastService.ID);
            listUpdateFlag = true;
            isNew = false;
        }

        if (!isNew) {
            foundService.setIpAddress(castDevice.getIpAddress().getHostAddress());
            foundService.setModelName(castDevice.getModelName());
            foundService.setModelNumber(castDevice.getDeviceVersion());
            foundService.setModelDescription(route.getDescription());
            foundService.setPort(castDevice.getServicePort());
            foundService.setDevice(castDevice);

            if (!foundService.getFriendlyName().equals(castDevice.getFriendlyName())) {
                foundService.setFriendlyName(castDevice.getFriendlyName());
                listUpdateFlag = true;
            }

            foundService.setLastDetection(new Date().getTime());

            foundServices.put(uuid, foundService);

            if (listUpdateFlag) {
                for (DiscoveryProviderListener listenter: serviceListeners) {
                    listenter.onServiceAdded(CastDiscoveryProvider.this, foundService);
                }
            }
        }
    }`