Commit 61a3d316 authored by Dan Sanders's avatar Dan Sanders Committed by Commit Bot

[webcodecs] Fix crash in VideoFrame.createImageBitmap() in workers

Without access to the shared main thread context,
VideoFrame.createImageBitmap() is unable to handle texture-backed
frames.

This CL does not fix the issue, but it does change it from a check
failure to a DOMException.

Bug: 1148849
Change-Id: I3f8c292022dc3cb8fd6625591d2384511e253ac2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2552901
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Commit-Queue: Chrome Cunningham <chcunningham@chromium.org>
Auto-Submit: Dan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarChrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829865}
parent 7acb7831
......@@ -438,6 +438,16 @@ ScriptPromise VideoFrame::CreateImageBitmap(ScriptState* script_state,
SkImage::MakeRasterData(info, image_pixels, bytes_per_row);
image = UnacceleratedStaticBitmapImage::Create(std::move(skImage));
} else {
if (!IsMainThread()) {
// TODO(crbug.com/1148849): We should either hop to the media thread and
// use the media context, or use the SharedGpuContext. Currently
// obtaining the media context requires synchronizing with the main
// thread, and PaintCanvasVideoRenderer is not compatible with
// SharedGpuContext.
exception_state.ThrowDOMException(DOMExceptionCode::kOperationError,
"Graphics context unavailable.");
return ScriptPromise();
}
scoped_refptr<viz::RasterContextProvider> raster_context_provider =
Platform::Current()->SharedMainThreadContextProvider();
auto* ri = raster_context_provider->RasterInterface();
......
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