lihaosky / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

Reconnecting to cached device fails when Chromecast is power-cycled (iOS SDK) #576

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Launch sender app
2. Connect to Chromecast
3. Shut down sender app
4. Turn off TV
5. Relaunch sender app (no attempt to reconnect is made since the Chromecast 
does not come back online - no call to deviceDidComeOnline:)
6. Shut down sender app
7. Turn TV back on and wait for Chromecast to start up
8. Relaunch sender app.

At this point the previously connected Chromecast sends the 
deviceDidComeOnline: callback, the cached ID (in lastDeviceID) is checked, and 
a call to connectToDevice: is made. The device's connection state sticks in 
GoogleCastStateConnecting until it errors out.

The desired behavior would be to connect properly to the cached device.

What version of the product are you using? On what operating system?

Chromecast firmware version 27946.
iOS v8.3

Please provide any additional information below.

This is a bit of an edge-case where the device running the sender app is 
shutdown (out of battery, etc.), and the TV is turned off. Then when the TV and 
device are both turned back on casting fails.

You can force the connection by opening the list of available Chromecast 
devices and selecting one, forcing the connection.  Doing this, you should 
notice that the cast icon is displaying the "attempting to connect" state.

Original issue reported on code.google.com by christop...@pluto.tv on 5 May 2015 at 11:47

GoogleCodeExporter commented 9 years ago
1) Just to clarify, you're seeing this issue on the Pluto.tv iOS sender app? 
Which version of the app are you using? 
2) What TV are you using and have you noticed this issue on any other 
TV's/monitors?
3) Does the error occur when using an Android sender device?
4) When did you first notice this issue occurring? Was it working correctly at 
any other point in time?
5) Can you reproduce the error, then capture and provide the receiver-side 
error logs?

Original comment by jonathan...@google.com on 8 May 2015 at 11:53

GoogleCodeExporter commented 9 years ago
Sorry for the delayed response.

1) Yes, 1.11.21, and 1.11.34 (the latest) is also doing it
2) Using a Vizio M322i-B1
3) Android devices seem to behave normally (as expected)
4) Not sure about that, as I inherited the code, as well as a few bugs. This 
was in the set of bugs, but I do not know when it was noticed.
5) Trying to get logs, but cannot get the debug console to behave. Can telnet 
to the Chromecast on port 9222, but the debug console is just empty (no DOM 
loaded or anything).

Original comment by christop...@pluto.tv on 12 May 2015 at 11:54

GoogleCodeExporter commented 9 years ago
The 2.6.0 SDK had some issues with backgrounding that should be addressed in 
the recent SDK release. Can you try updating to the latest SDK version and see 
if the problem still occurs?

Original comment by jonathan...@google.com on 13 May 2015 at 7:27

GoogleCodeExporter commented 9 years ago
Hi Jonathan,

Updated to 2.6.1 and re-run the steps above.

First thing I notice is that now, when I hit step 5, the Chromecast connection 
icon is lit as if it were connected, and clicking on it to enumerate the 
available devices show the Chromecast I was connected to (with the caption, 
"Playing Pluto TV") even though the Chromecast is off.

The GCKDeviceScanner is somehow finding it, and calling notifyDeviceOnline:.

Once I get to step 8, I see the icon still lit, and the device list shows the 
Chromecast (now turned back on) with no caption. The reconnect still fails.

My connect/reconnect code is straight from a Google example app, handling 
deviceDidComeOnline: with:

- (void)deviceDidComeOnline:(GCKDevice *)device {
    NSLog(@"device found - %@", device.friendlyName);

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *lastDeviceID = [defaults objectForKey:@"lastDeviceID"];
    if (lastDeviceID != nil && [[device deviceID] isEqualToString:lastDeviceID]) {
        self.isReconnecting = true;
        [self connectToDevice:device];
    }

    // Trigger an update in the next run loop so we pick up the updated devices array.
    [self performSelector:@selector(updateCastIconButtonStates) withObject:nil afterDelay:0];
    if ([self.delegate respondsToSelector:@selector(didDiscoverDeviceOnNetwork)]) {
        [self.delegate didDiscoverDeviceOnNetwork];
    }
}

and the code for connectToDevice:

- (void)connectToDevice:(GCKDevice *)device {
    NSLog(@"Device address: %@:%d", device.ipAddress, (unsigned int) device.servicePort);
    self.selectedDevice = device;

    NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
    NSString *appIdentifier = [info objectForKey:@"CFBundleIdentifier"];
    self.deviceManager =
            [[GCKDeviceManager alloc] initWithDevice:self.selectedDevice clientPackageName:appIdentifier];
    self.deviceManager.delegate = self;
    [self.deviceManager connect];

    // Start animating the cast connect images.
    UIButton *chromecastButton = (UIButton *) self.chromecastBarButton.customView;
    chromecastButton.tintColor = [UIColor whiteColor];
    chromecastButton.imageView.animationImages =
            @[[UIImage imageNamed:@"icon_cast_on0.png"], [UIImage imageNamed:@"icon_cast_on1.png"],
                    [UIImage imageNamed:@"icon_cast_on2.png"], [UIImage imageNamed:@"icon_cast_on1.png"]];
    chromecastButton.imageView.animationDuration = 2;
    [chromecastButton.imageView startAnimating];

    [[NSNotificationCenter defaultCenter] postNotificationName:kConnectingToGoogleCastDevice object:nil];
}

Original comment by christop...@pluto.tv on 13 May 2015 at 8:04

GoogleCodeExporter commented 9 years ago
Thanks for the update, Christopher. We're looking into the issue. Also, the 
firmware update should have fixed the debugging problem. Is the debug console 
working now? If so, could you reproduce the issue and provide the error logs? 
Note that if you're still getting a blank screen, you may have to click on the 
shield icon at the right of the address bar.

Original comment by jonathan...@google.com on 13 May 2015 at 8:43

GoogleCodeExporter commented 9 years ago
Are you still seeing this issue? If so, can you provide the requested 
information?

Original comment by jonathan...@google.com on 20 May 2015 at 4:59

GoogleCodeExporter commented 9 years ago
Closing due to a lack of response. If you can confirm that you're still 
experiencing the issue and can provide the requested information, we can reopen 
the ticket.

Original comment by jonathan...@google.com on 27 May 2015 at 8:55