Skip to content

Commit

Permalink
Add ScopedAllowIO in WebrtcTransport when shutting down WebRTC session.
Browse files Browse the repository at this point in the history
PeerConnection creates new threads internally and shuts them down when
connection is closed. This is a blocking operation, so Debug builds were
DCHECK'ing every time connection is terminated. Added ScopedAllowIO to
work around this issue.

BUG=660081

Review-Url: https://codereview.chromium.org/2567533002
Cr-Commit-Position: refs/heads/master@{#437711}
  • Loading branch information
SergeyUlanov authored and Commit bot committed Dec 10, 2016
1 parent 759bba6 commit 2c41f98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions PRESUBMIT.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
r"^net[\\\/]test[\\\/]spawned_test_server[\\\/]local_test_server\.cc$",
r"^net[\\\/]test[\\\/]test_data_directory\.cc$",
r"^net[\\\/]url_request[\\\/]test_url_fetcher_factory\.cc$",
r"^remoting[\\\/]protocol[\\\/]webrtc_transport\.cc$",
r"^ui[\\\/]base[\\\/]material_design[\\\/]"
"material_design_controller\.cc$",
r"^ui[\\\/]gl[\\\/]init[\\\/]gl_initializer_mac\.cc$",
Expand Down
9 changes: 8 additions & 1 deletion remoting/protocol/webrtc_transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "jingle/glue/thread_wrapper.h"
#include "remoting/protocol/authenticator.h"
Expand Down Expand Up @@ -194,7 +195,13 @@ class WebrtcTransport::PeerConnectionWrapper
peer_connection_ = peer_connection_factory_->CreatePeerConnection(
rtc_config, &constraints, std::move(port_allocator), nullptr, this);
}
virtual ~PeerConnectionWrapper() { peer_connection_->Close(); }
virtual ~PeerConnectionWrapper() {
// PeerConnection creates threads internally, which are stopped when the
// connection is closed. Thread.Stop() is a blocking operation.
// See crbug.com/660081.
base::ThreadRestrictions::ScopedAllowIO allow_io;
peer_connection_->Close();
}

WebrtcAudioModule* audio_module() {
return audio_module_.get();
Expand Down

0 comments on commit 2c41f98

Please sign in to comment.