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

Issue 684664 link

Starred by 2 users

Issue metadata

Status: Verified
Owner:
Last visit > 30 days ago
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Mac
Pri: 1
Type: Bug



Sign in to add a comment

[Presentation API] PresentationConnection.onconnect event handler sometimes not called due to a race condition

Project Member Reported by taku...@chromium.org, Jan 24 2017

Issue description

Moved here from b/34103696.
Observed on macOS (Beta 56, Canary 57, TOT) and Linux (Beta 56, Dev 57)

There is a race condition between PresentationController::registerConnection() and PresentationController::didChangeSessionState(). When didChangeSessionState() gets called before registerConnection(), it's a no-op, and results in the onconnect event not firing.
 

Comment 1 by sko...@chromium.org, Jan 24 2017

Labels: ReleaseBlock-Stable M-57
Status: Available (was: Untriaged)
We should fix this before M57 goes to stable.
Cc: imch...@chromium.org zhaobin@chromium.org
Owner: imch...@chromium.org
Status: Assigned (was: Available)
Status: Started (was: Assigned)
Project Member

Comment 5 by bugdroid1@chromium.org, Jan 26 2017

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

commit 1ebdd16432860b90eaaeaba7042c2e9761b17ef7
Author: imcheng <imcheng@chromium.org>
Date: Thu Jan 26 22:01:52 2017

[Presentation API] Fix race condition in which state change is lost.

Currently there is a race condition between the PresentationConnection
being returned to PresentationDispatcher on a successful start() or
reconnect(), and PresentationDispatcher being notified by the browser
that the state change has become connected.

Although PresentationServiceImpl issues the state change strictly after
executing the callback returning the PresentationConnection, it appears
that they are using distinct independent message pipes, which do not
guarantee order of arrival between these two messages. If the state
change message arrives first, then it will be lost due to the
connection not yet registered with Blink at that point in time.

The fix here is to change state to connected in Blink, after the
PresentationConnection is registered.

This fix needs to be merged back to 57.

Additional test assertions will be in a followup patch.

BUG= 684664 

Review-Url: https://codereview.chromium.org/2653683006
Cr-Commit-Position: refs/heads/master@{#446465}

[modify] https://crrev.com/1ebdd16432860b90eaaeaba7042c2e9761b17ef7/content/browser/presentation/presentation_service_impl.cc
[modify] https://crrev.com/1ebdd16432860b90eaaeaba7042c2e9761b17ef7/content/browser/presentation/presentation_service_impl.h
[modify] https://crrev.com/1ebdd16432860b90eaaeaba7042c2e9761b17ef7/content/browser/presentation/presentation_service_impl_unittest.cc
[modify] https://crrev.com/1ebdd16432860b90eaaeaba7042c2e9761b17ef7/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp

Comment 6 by mfo...@chromium.org, Jan 30 2017

Derek is this fixed?  Can you verify in Canary so we can request a merge to M57?
 Issue 655840  has been merged into this issue.
Status: Verified (was: Started)
I just verified it works in canary 58.0.2995.0.
Labels: Merge-TBD
[Auto-generated comment by a script] We noticed that this issue is targeted for M-57; it appears the fix may have landed after branch point, meaning a merge might be required. Please confirm if a merge is required here - if so add Merge-Request-57 label, otherwise remove Merge-TBD label. Thanks.
Labels: -Merge-TBD Merge-Request-57
Project Member

Comment 11 by sheriffbot@chromium.org, Jan 30 2017

Labels: -Merge-Request-57 Hotlist-Merge-Approved Merge-Approved-57
Your change meets the bar and is auto-approved for M57. Please go ahead and merge the CL to branch 2987 manually. Please contact milestone owner if you have questions.
Owners: amineer@(clank), cmasso@(bling), ketakid@(cros), govind@(desktop)

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 12 by bugdroid1@chromium.org, Jan 30 2017

Labels: -merge-approved-57 merge-merged-2987
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/cdf4402738b87ca888eb12baa02d1b78bd396b4a

commit cdf4402738b87ca888eb12baa02d1b78bd396b4a
Author: Derek Cheng <imcheng@chromium.org>
Date: Mon Jan 30 22:16:55 2017

[Presentation API] Fix race condition in which state change is lost.

Currently there is a race condition between the PresentationConnection
being returned to PresentationDispatcher on a successful start() or
reconnect(), and PresentationDispatcher being notified by the browser
that the state change has become connected.

Although PresentationServiceImpl issues the state change strictly after
executing the callback returning the PresentationConnection, it appears
that they are using distinct independent message pipes, which do not
guarantee order of arrival between these two messages. If the state
change message arrives first, then it will be lost due to the
connection not yet registered with Blink at that point in time.

The fix here is to change state to connected in Blink, after the
PresentationConnection is registered.

This fix needs to be merged back to 57.

Additional test assertions will be in a followup patch.

BUG= 684664 

Review-Url: https://codereview.chromium.org/2653683006
Cr-Commit-Position: refs/heads/master@{#446465}
(cherry picked from commit 1ebdd16432860b90eaaeaba7042c2e9761b17ef7)

Review-Url: https://codereview.chromium.org/2661053002 .
Cr-Commit-Position: refs/branch-heads/2987@{#198}
Cr-Branched-From: ad51088c0e8776e8dcd963dbe752c4035ba6dab6-refs/heads/master@{#444943}

[modify] https://crrev.com/cdf4402738b87ca888eb12baa02d1b78bd396b4a/content/browser/presentation/presentation_service_impl.cc
[modify] https://crrev.com/cdf4402738b87ca888eb12baa02d1b78bd396b4a/content/browser/presentation/presentation_service_impl.h
[modify] https://crrev.com/cdf4402738b87ca888eb12baa02d1b78bd396b4a/content/browser/presentation/presentation_service_impl_unittest.cc
[modify] https://crrev.com/cdf4402738b87ca888eb12baa02d1b78bd396b4a/third_party/WebKit/Source/modules/presentation/PresentationConnection.cpp

Project Member

Comment 13 by bugdroid1@chromium.org, Jan 31 2017

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

commit 54e7828cdcb38fda68c7a5bbc7ea1d7896f96588
Author: imcheng <imcheng@chromium.org>
Date: Tue Jan 31 03:59:32 2017

[MR tests] Assert initial state / state change for reconnect case.

Followup to https://codereview.chromium.org/2653683006/.

Refactor logic that asserts initial state of a PresentationConnection
into a helper method and also use it in the reconnect success case.

BUG= 684664 

Review-Url: https://codereview.chromium.org/2654003002
Cr-Commit-Position: refs/heads/master@{#447184}

[modify] https://crrev.com/54e7828cdcb38fda68c7a5bbc7ea1d7896f96588/chrome/test/media_router/resources/common.js

Sign in to add a comment