Commit 32deecc6 authored by Matt Wolenetz's avatar Matt Wolenetz Committed by Commit Bot

MSE-in-Workers: Avoid StringImpl refcount race in isTypeSupported

HTMLMediaElement::GetSupportsType is used from
MediaSource::isTypeSupported(). Historically,
MediaSource.isTypeSupported() was allowed only on the main "window"
thread, but this is changing with MSE-in-Workers. Tests of experimental
MSE-in-Workers revealed a refcount race on a DEFINE_STATIC_LOCAL String
in GetSupportsType.

This change instead uses a String built on the stack to continue to
support simultaneous queries without racing a shared StringImpl's
refcount. This should also help at least prevent further regression
tracked previously in bug 809912.

BUG=878133,809912

Change-Id: I35f6aff46d0a65dfc591a271d470dae24c75089c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2469453Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Commit-Queue: Matthew Wolenetz <wolenetz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817578}
parent b9277923
...@@ -399,10 +399,9 @@ std::ostream& operator<<(std::ostream& stream, ...@@ -399,10 +399,9 @@ std::ostream& operator<<(std::ostream& stream,
constexpr double HTMLMediaElement::kMinPlaybackRate; constexpr double HTMLMediaElement::kMinPlaybackRate;
constexpr double HTMLMediaElement::kMaxPlaybackRate; constexpr double HTMLMediaElement::kMaxPlaybackRate;
// static
MIMETypeRegistry::SupportsType HTMLMediaElement::GetSupportsType( MIMETypeRegistry::SupportsType HTMLMediaElement::GetSupportsType(
const ContentType& content_type) { const ContentType& content_type) {
DEFINE_STATIC_LOCAL(const String, codecs, ("codecs"));
// TODO(https://crbug.com/809912): Finding source of mime parsing crash. // TODO(https://crbug.com/809912): Finding source of mime parsing crash.
static base::debug::CrashKeyString* content_type_crash_key = static base::debug::CrashKeyString* content_type_crash_key =
base::debug::AllocateCrashKeyString("media_content_type", base::debug::AllocateCrashKeyString("media_content_type",
...@@ -413,7 +412,7 @@ MIMETypeRegistry::SupportsType HTMLMediaElement::GetSupportsType( ...@@ -413,7 +412,7 @@ MIMETypeRegistry::SupportsType HTMLMediaElement::GetSupportsType(
String type = content_type.GetType().DeprecatedLower(); String type = content_type.GetType().DeprecatedLower();
// The codecs string is not lower-cased because MP4 values are case sensitive // The codecs string is not lower-cased because MP4 values are case sensitive
// per http://tools.ietf.org/html/rfc4281#page-7. // per http://tools.ietf.org/html/rfc4281#page-7.
String type_codecs = content_type.Parameter(codecs); String type_codecs = content_type.Parameter("codecs");
if (type.IsEmpty()) if (type.IsEmpty())
return MIMETypeRegistry::kIsNotSupported; return MIMETypeRegistry::kIsNotSupported;
......
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