diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2024-04-18 16:08:16 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2024-05-10 12:43:55 +0200 |
commit | 77870eff29c5d91c7c90505b3591b462df338c26 (patch) | |
tree | 83f16861352fe80749a63bf2e00090722cbf18be /src/core | |
parent | 2b42577eece3c7f43ff1495374326e9bdc0140e1 (diff) |
Fix crash when playing video with disabled NativePixmap support
The VideoRenderer tries to create VideoFrames backed by native
textures if possible. This leads to a crash or assert if GBM and
NativePixmaps are not supported. Replace the corresponding asserts with
early returns. The renderer is able to handle the case when
NativePixmaps couldn't been created.
Also disable native texture backed VideoFrames for Nvidia by default to
avoid this code path.
Pick-to: 6.7
Change-Id: I5f271af99875dfbc28350c6d76d3bf7a1a697b9f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ozone/surface_factory_qt.cpp | 12 | ||||
-rw-r--r-- | src/core/web_engine_context.cpp | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index 4a2006a2d..04e6ec28f 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -92,7 +92,8 @@ scoped_refptr<gfx::NativePixmap> SurfaceFactoryQt::CreateNativePixmap( gfx::BufferUsage usage, absl::optional<gfx::Size> framebuffer_size) { - Q_ASSERT(SupportsNativePixmaps()); + if (!SupportsNativePixmaps()) + return nullptr; #if QT_CONFIG(opengl) if (framebuffer_size && !gfx::Rect(size).Contains(gfx::Rect(*framebuffer_size))) @@ -141,7 +142,11 @@ void SurfaceFactoryQt::CreateNativePixmapAsync( gfx::BufferUsage usage, NativePixmapCallback callback) { - Q_ASSERT(SupportsNativePixmaps()); + if (!SupportsNativePixmaps()) { + std::move(callback).Run(nullptr); + return; + } + // CreateNativePixmap is non-blocking operation. Thus, it is safe to call it // and return the result with the provided callback. std::move(callback).Run(CreateNativePixmap(widget, device_queue, size, format, usage)); @@ -154,7 +159,8 @@ SurfaceFactoryQt::CreateNativePixmapFromHandle( gfx::BufferFormat format, gfx::NativePixmapHandle handle) { - Q_ASSERT(SupportsNativePixmaps()); + if (!SupportsNativePixmaps()) + return nullptr; #if QT_CONFIG(opengl) gfx::NativePixmapHandle bufferHandle; diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp index 2017fa80c..faf9bd542 100644 --- a/src/core/web_engine_context.cpp +++ b/src/core/web_engine_context.cpp @@ -927,8 +927,10 @@ WebEngineContext::WebEngineContext() } #if defined(USE_OZONE) - if (GPUInfo::instance()->vendor() == GPUInfo::Nvidia) + if (GPUInfo::instance()->vendor() == GPUInfo::Nvidia) { disableFeatures.push_back(media::kVaapiVideoDecodeLinux.name); + parsedCommandLine->AppendSwitch(switches::kDisableGpuMemoryBufferVideoFrames); + } #if QT_CONFIG(webengine_vulkan) if (QQuickWindow::graphicsApi() == QSGRendererInterface::Vulkan) { |