Commit 5baf224f authored by Sergey Ulanov's avatar Sergey Ulanov Committed by Commit Bot

[Fuchsia] Fix crash in DefaultDecoderFactory

Previously DefaultDecoderFactory could crash when creating decoders
after the GPU context has been lost because it was assuming that
GetMediaContextProvider() always returns a valid result. Fixed it to it
to validate the result before trying to use it.

Bug: 1057959
Change-Id: I767a8fa7dcfcfb122be98449cc1aa46c43ceae62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2135531
Commit-Queue: Sergey Ulanov <sergeyu@chromium.org>
Auto-Submit: Sergey Ulanov <sergeyu@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756374}
parent bd0741d0
......@@ -121,10 +121,22 @@ void DefaultDecoderFactory::CreateVideoDecoders(
#if defined(OS_FUCHSIA)
if (gpu_factories) {
auto* context_provider = gpu_factories->GetMediaContextProvider();
DCHECK(context_provider);
video_decoders->push_back(
CreateFuchsiaVideoDecoder(gpu_factories->SharedImageInterface(),
context_provider->ContextSupport()));
// GetMediaContextProvider() may return nullptr when the context was lost
// (e.g. after GPU process crash). To handle this case RenderThreadImpl
// creates a new GpuVideoAcceleratorFactories with a new ContextProvider
// instance, but there is no way to get it here. For now just don't add
// FuchsiaVideoDecoder in that scenario.
//
// TODO(crbug.com/580386): Handle context loss properly.
if (context_provider) {
video_decoders->push_back(
CreateFuchsiaVideoDecoder(gpu_factories->SharedImageInterface(),
context_provider->ContextSupport()));
} else {
DLOG(ERROR)
<< "Can't created FuchsiaVideoDecoder due to GPU context loss.";
}
}
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
......
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