Commit 6622916f authored by John Williams's avatar John Williams Committed by Commit Bot

[Cast MRP] Added workarounds for crashes in JoinSession().

There isn't a known repro, so this CL is a best effort to fix the
likely cause of the crashes.

Bug: 1114067
Change-Id: I2416be1f2eddef8c3a954146ea9c905f78421a29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343596
Commit-Queue: John Williams <jrw@chromium.org>
Auto-Submit: John Williams <jrw@chromium.org>
Reviewed-by: default avatarTakumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796130}
parent d4aaf40e
...@@ -322,7 +322,7 @@ void CastActivityManager::JoinSession( ...@@ -322,7 +322,7 @@ void CastActivityManager::JoinSession(
media_sink_service_->GetSinkById(activity->route().media_sink_id()); media_sink_service_->GetSinkById(activity->route().media_sink_id());
if (!sink) { if (!sink) {
logger_->LogError(mojom::LogCategory::kRoute, kLoggerComponent, logger_->LogError(mojom::LogCategory::kRoute, kLoggerComponent,
"Cannot find the sink to join with sind_id.", "Cannot find the sink to join with sink_id.",
activity->route().media_sink_id(), activity->route().media_sink_id(),
cast_source.source_id(), presentation_id); cast_source.source_id(), presentation_id);
std::move(callback).Run(base::nullopt, nullptr, std::move(callback).Run(base::nullopt, nullptr,
...@@ -334,7 +334,26 @@ void CastActivityManager::JoinSession( ...@@ -334,7 +334,26 @@ void CastActivityManager::JoinSession(
mojom::RoutePresentationConnectionPtr presentation_connection = mojom::RoutePresentationConnectionPtr presentation_connection =
activity->AddClient(cast_source, origin, tab_id); activity->AddClient(cast_source, origin, tab_id);
DCHECK(activity->session_id()); if (!activity->session_id()) {
// This should never happen, but it looks like maybe it does. See
// crbug.com/1114067.
NOTREACHED();
static const char kErrorMessage[] = "Internal error: missing session ID";
// Checking for |logger_| here is pure paranoia, but this code only exists
// to fix a crash we can't reproduce, so creating even a tiny possibility of
// a different crash seems like a bad idea.
if (logger_) {
// The empty string parameters could have real values, but they're omitted
// out of an abundance of caution, and they're not especially relevant to
// this error anyway.
logger_->LogError(mojom::LogCategory::kRoute, kLoggerComponent,
kErrorMessage, "", "", "");
}
std::move(callback).Run(base::nullopt, nullptr, kErrorMessage,
RouteRequestResult::ResultCode::UNKNOWN_ERROR);
return;
}
const CastSession* session = const CastSession* session =
session_tracker_->GetSessionById(*activity->session_id()); session_tracker_->GetSessionById(*activity->session_id());
const std::string& client_id = cast_source.client_id(); const std::string& client_id = cast_source.client_id();
......
...@@ -162,6 +162,22 @@ void CastMediaRouteProvider::JoinRoute(const std::string& media_source, ...@@ -162,6 +162,22 @@ void CastMediaRouteProvider::JoinRoute(const std::string& media_source,
return; return;
} }
if (!activity_manager_) {
// This should never happen, but it looks like maybe it does. See
// crbug.com/1114067.
NOTREACHED();
// This message will probably go unnoticed, but it's here to give some
// indication of what went wrong, since NOTREACHED() is compiled out of
// release builds. It would be nice if we could log a message to |logger_|,
// but it's initialized in the same place as |activity_manager_|, so it's
// almost certainly not available here.
LOG(ERROR) << "missing activity manager";
std::move(callback).Run(base::nullopt, nullptr,
"Internal error: missing activity manager",
RouteRequestResult::ResultCode::UNKNOWN_ERROR);
return;
}
activity_manager_->JoinSession(*cast_source, presentation_id, origin, tab_id, activity_manager_->JoinSession(*cast_source, presentation_id, origin, tab_id,
incognito, std::move(callback)); incognito, std::move(callback));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment