New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593669 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug-Regression

Blocked on:
issue 595373



Sign in to add a comment

Can't switch to new video when casting

Project Member Reported by aber...@chromium.org, Mar 10 2016

Issue description

Symptoms are similar to  issue 577283 , but works on Beta (49.0.2623.91), fails on Dev build (50.0.2661.9) or ToT build.

1. Go to videojs.com
2. Cast first video.
3. Once playing cast second video on page (first customer example)

Expected result - second video plays on Chromecast
Actual result - first video stops playing on Chromecast, and Chrome app stops on Chromecast (returning to home screen).

All tests, including tests switching videos, pass on ToT.
 
Also fails on ChromePublic.
Actually only seems to fail on videojs.com, not on other pages. The behaviour is also not entirely consistent, it sometimes doesn't fail.
Owner: aber...@chromium.org
Status: Assigned (was: Untriaged)
From bisecting the problem started with:

commit 16865ed7e365226b34c48503828e4ed255241e53
Author: aberent <aberent@chromium.org>
Date:   Wed Jan 20 08:44:37 2016 -0800

    Only show cast button if video can be cast
    
    This moves the check of the CORS headers for casting to the
    initialization of the RemoteMediaPlayerBridge. As a result we can
    suppress the cast button if the video isn't playable on Chromecast.
    
    BUG= 539406 
    
    Review URL: https://codereview.chromium.org/1607043002
    
    Cr-Commit-Position: refs/heads/master@{#370412}

which makes some sense. Still need to investigate what went wrong here, and why the tests still pass. Also, strangely, switching videos on http://crhtmltest.appspot.com/static/video.html seems to work correctly, and after doing so then switching videos on videojs.com sometimes works correctly (I don't yet understand the pattern).
Blockedon: 594676
I am delaying further work on this, since the video controls are now broken on ToT, see  issue 594676 .
Components: Internals>Cast>MediaFling
Blockedon: -594676
Turns out that  issue 594676  can be avoided by using an official build, so it is no longer blocking. It now seems that the seek that happens when the second video is cast is returning an error, and, on getting this error, Clank is disconnecting from Chromecast.

I think I now partly understand the bug; the sequence is:

1. The user asks to cast the video.
2. Clank initialized everything, stops the old video, and sends a play request to Chromecast.
3. The Clank Cast code receives a pause request from the C++ side (I am not sure where this is coming from, but it could be related to  issue 595373 .
4. The pause request immediately calls UpdateState() (rather than waiting for Chromecast to respond). See https://code.google.com/p/chromium/codesearch#chromium/src/chrome/android/java/src/org/chromium/chrome/browser/media/remote/DefaultMediaRouteController.java&l=226, and the comments that proceed this.
5. UpdateState() interpretes this to mean that the video is now being played and calls onCasting().
6. onCasting() notices that this is the first time that it has been called for this video, and does startup actions including sending a seek to Chromecast.
7. Because the video is not yet loaded the Chromecast support code returns an error.
8. On receiving the error the Clank Cast code stops the video playing and disconnects!
Saved too soon. There are at least three problems here:
- We should not be getting a pause request.
- The pause request should be passed to Chromecast immediately, but should be pending until the video is being cast.
- The local state change (which, as explained in the comments, we do need) should not be interpreted to mean that the video is being cast.

I still don't understand why I am only seeing this with this site, but all this does depend on various timing races, so it may not be surprising that it doesn't always happen.
Cc: avayvod@chromium.org mlamouri@chromium.org
https://codereview.chromium.org/1822653002/#ps1 fixes the second and third issues, but, unfortunately, in its current form, means that the second video played always starts paused. I still need to investigate this, but it is probably a version of  issue 595373 .

I also need to understand why this isn't being picked up by the tests.

+avayvod, +mlamouri for information.
Blockedon: 595373
Status: Started (was: Assigned)
I have confirmed that the remaining problem is caused by AudioFocus ( issue 595373 ). The reason it doesn't happen with the first video played is that it is only a problem if a video is playing locally. See  issue 595373  for further discussion of the AudioFocus problem.
Labels: Merge-Request-50 M-50
Labels: -Merge-Request-50
Project Member

Comment 13 by bugdroid1@chromium.org, Mar 24 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/829655949350c19eea8231f2e2da34679bc42d21

commit 829655949350c19eea8231f2e2da34679bc42d21
Author: aberent <aberent@chromium.org>
Date: Thu Mar 24 17:07:00 2016

Distingush between displayed and remote playback state.

Fixes two of the problems causing  bug 593669 .

distinguishes between the displayed playback state (which, for example
swiches to paused as soon as the pause button is pressed) and the
remote playback state. Hence avoids side effects when the only the
displayed playback state changes.

Also prevents pause being sent to Chromecast too early.

BUG= 593669 

Review URL: https://codereview.chromium.org/1822653002

Cr-Commit-Position: refs/heads/master@{#383082}

[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/java/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteController.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/java/src/org/chromium/chrome/browser/media/remote/DefaultMediaRouteController.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/java/src/org/chromium/chrome/browser/media/remote/ExpandedControllerActivity.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/java/src/org/chromium/chrome/browser/media/remote/RemoteMediaPlayerBridge.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/java/src/org/chromium/chrome/browser/media/remote/RemoteMediaPlayerController.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/javatests/src/org/chromium/chrome/browser/media/remote/CastTestBase.java
[modify] https://crrev.com/829655949350c19eea8231f2e2da34679bc42d21/chrome/android/junit/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteControllerTest.java

Labels: Merge-Request-50

Comment 15 by tin...@google.com, Mar 29 2016

Labels: -Merge-Request-50 Merge-Approved-50 Hotlist-Merge-Approved
Your change meets the bar and is auto-approved for M50 (branch: 2661)
Project Member

Comment 16 by bugdroid1@chromium.org, Mar 29 2016

Labels: -merge-approved-50 merge-merged-2661
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/7d077eb4b5ffc7b874bdf020e39cca24f55966cf

commit 7d077eb4b5ffc7b874bdf020e39cca24f55966cf
Author: Anthony Berent <aberent@chromium.org>
Date: Tue Mar 29 09:41:14 2016

Distingush between displayed and remote playback state.

Fixes two of the problems causing  bug 593669 .

distinguishes between the displayed playback state (which, for example
swiches to paused as soon as the pause button is pressed) and the
remote playback state. Hence avoids side effects when the only the
displayed playback state changes.

Also prevents pause being sent to Chromecast too early.

BUG= 593669 

Review URL: https://codereview.chromium.org/1822653002

Cr-Commit-Position: refs/heads/master@{#383082}
(cherry picked from commit 829655949350c19eea8231f2e2da34679bc42d21)

Review URL: https://codereview.chromium.org/1839013002 .

Cr-Commit-Position: refs/branch-heads/2661@{#418}
Cr-Branched-From: ef6f6ae5e4c96622286b563658d5cd62a6cf1197-refs/heads/master@{#378081}

[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/java/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteController.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/java/src/org/chromium/chrome/browser/media/remote/CastNotificationControl.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/java/src/org/chromium/chrome/browser/media/remote/DefaultMediaRouteController.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/java/src/org/chromium/chrome/browser/media/remote/ExpandedControllerActivity.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/java/src/org/chromium/chrome/browser/media/remote/MediaRouteController.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/java/src/org/chromium/chrome/browser/media/remote/RemoteMediaPlayerBridge.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/java/src/org/chromium/chrome/browser/media/remote/RemoteMediaPlayerController.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/javatests/src/org/chromium/chrome/browser/media/remote/CastTestBase.java
[modify] https://crrev.com/7d077eb4b5ffc7b874bdf020e39cca24f55966cf/chrome/android/junit/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteControllerTest.java

Status: Fixed (was: Started)

Sign in to add a comment