I try to enable WebGL in QWebEngineView with PyQt6 and PySide6 like this:
view.settings().setAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled, True)
view.setUrl(QUrl("https://get.webgl.org/"))
But the result is the same for PyQt6 and PySide6:
Console output:
D3D11 smoke test failed (failed to create vertex shader)
----------------------
True
doh set to "" -- SystemOnly
D3D11 smoke test failed (failed to create vertex shader)
js: Unrecognized Content-Security-Policy directive 'image-src'.
PySide 6.1.1 includes WebEngine. For PyQt 6.1.1 the WebEngine must be installed using this command: pip install PyQt6-WebEngine
Code example:
main.py
import sys
from PyQt6.QtCore import QUrl
from PyQt6.QtWebEngineCore import QWebEngineSettings
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QWidget
class Widget(QWidget):
def __init__(self):
super().__init__()
self.setWindowTitle("QWebEngineView, PyQt6, Python")
self.resize(650, 400)
layout = QVBoxLayout()
view = QWebEngineView()
layout.addWidget(view)
self.setLayout(layout)
# view.load(QUrl("file:///web-project/index.html"))
view.settings().setAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled, True)
print("----------------------")
print(view.settings().testAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled))
view.setUrl(QUrl("https://get.webgl.org/"))
if __name__ == "__main__":
app = QApplication(sys.argv)
w = Widget()
w.show()
sys.exit(app.exec())
Added
I tried this url: view.setUrl(QUrl("chrome://gpu"))
how ekhumoro wrote in the comments. So WebGL is disabled. How to enable it?
Whole report:
Graphics Feature Status
Canvas: Software only. Hardware acceleration disabled
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Software only. Hardware acceleration disabled
Multiple Raster Threads: Disabled
OpenGL: Disabled
Rasterization: Software only. Hardware acceleration disabled
Raw Draw: Disabled
Video Decode: Software only. Hardware acceleration disabled
Video Encode: Software only. Hardware acceleration disabled
Vulkan: Disabled
WebGL: Disabled
WebGL2: Disabled
WebGPU: Disabled
Driver Bug Workarounds
clear_uniforms_before_first_program_use
decode_encode_srgb_for_generatemipmap
disable_vp_scaling
disable_vp_super_resolution
enable_webgl_timer_query_extensions
exit_on_context_lost
disabled_extension_GL_KHR_blend_equation_advanced
disabled_extension_GL_KHR_blend_equation_advanced_coherent
disabled_extension_GL_MESA_framebuffer_flip_y
Problems Detected
Gpu compositing has been disabled, either via blocklist, about:flags or the command line. The browser will fall back to software compositing and hardware acceleration will be unavailable.
Disabled Features: gpu_compositing
GPU process was unable to boot: GPU access is disabled through commandline switch --disable-gpu.
Disabled Features: all
GPU rasterization should only be enabled on NVIDIA and Intel and AMD RX-R2 GPUs with DX11+ or any GPU using ANGLE's GL backend.: 1047002
Disabled Features: gpu_rasterization
Some drivers are unable to reset the D3D device in the GPU process sandbox
Applied Workarounds: exit_on_context_lost
Clear uniforms before first program use on all platforms: 124764, 349137
Applied Workarounds: clear_uniforms_before_first_program_use
Disable KHR_blend_equation_advanced until cc shaders are updated: 661715
Applied Workarounds: disable(GL_KHR_blend_equation_advanced), disable(GL_KHR_blend_equation_advanced_coherent)
Decode and Encode before generateMipmap for srgb format textures on Windows: 634519
Applied Workarounds: decode_encode_srgb_for_generatemipmap
Expose WebGL's disjoint_timer_query extensions on platforms with site isolation: 808744, 870491
Applied Workarounds: enable_webgl_timer_query_extensions
Don't use video processor scaling on non-Intel, non-NVIDIA GPUs.: 993233
Applied Workarounds: disable_vp_scaling
Disable GL_MESA_framebuffer_flip_y for desktop GL: 964010
Applied Workarounds: disable(GL_MESA_framebuffer_flip_y)
Only enable video processor super resolution on Intel Gen10+ GPUs and NVIDIA GPUs with 530+ drivers: 1318380
Applied Workarounds: disable_vp_super_resolution
Version Information
Data exported
2023-12-20T18:20:34.385Z
Chrome version
python/3.8.10150.1013
Operating system
Windows NT 10.0.18362
Software rendering list URL
https://chromium.googlesource.com/chromium/src/+/3bd7c498c6d8c90fafb56211b896e34bd4308ca0/gpu/config/software_rendering_list.json
Driver bug list URL
https://chromium.googlesource.com/chromium/src/+/3bd7c498c6d8c90fafb56211b896e34bd4308ca0/gpu/config/gpu_driver_bug_list.json
ANGLE commit id
unknown hash
2D graphics backend
Skia/112 4dc670a8c5575180caa3d4d03f1e05da0177240d
Command Line
main.py --browser-subprocess-path="E:\ProgramFiles\Python\Python38\lib\site-packages\PyQt6\Qt6\bin\QtWebEngineProcess.exe" --application-name=python --enable-threaded-compositing --disable-speech-api --disable-blink-features=EyeDropperAPI --use-adapter-luid=0,55839 --enable-features=NetworkServiceInProcess2,TracingServiceInProcess --disable-features=ConsolidatedMovementXY,InstalledApp,EyeDropper,BackgroundFetch,WebOTP,WebPayments,WebUSB --use-gl=disabled --in-process-gpu --disable-gpu --gpu-preferences=UAAAAAAAAADoAAAIAAAAAAAAAAAAAAAAAABgAAAAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAGAAAAAAAAAAIAAAAAAAAAAgAAAAAAAAACAAAAAAAAAA=
Driver Information
Initialization time
0
In-process GPU
true
Passthrough Command Decoder
true
Sandboxed
false
GPU0
VENDOR= 0x0000, DEVICE=0x0000, LUID={0,0}
Optimus
false
AMD switchable
false
Desktop compositing
Aero Glass
Direct composition
false
Supports overlays
false
YUY2 overlay support
NONE
NV12 overlay support
NONE
BGRA8 overlay support
NONE
RGB10A2 overlay support
NONE
Diagonal Monitor Size of \\.\DISPLAY1
15.5"
Driver D3D12 feature level
Not supported
Driver Vulkan API version
Not supported
GPU CUDA compute capability major version
0
Pixel shader version
Vertex shader version
Max. MSAA samples
Machine model name
Machine model version
GL implementation
disabled
ANGLE implementation
none
Display type
GL_VENDOR
Disabled
GL_RENDERER
Disabled
GL_VERSION
Disabled
GL_EXTENSIONS
Disabled Extensions
GL_KHR_blend_equation_advanced GL_KHR_blend_equation_advanced_coherent GL_MESA_framebuffer_flip_y
Disabled WebGL Extensions
Window system binding vendor
Window system binding version
Window system binding extensions
Direct rendering version
unknown
Reset notification strategy
0x0000
GPU process crash count
0
gfx::BufferFormats supported for allocation and texturing
R_8: not supported, R_16: not supported, RG_88: not supported, RG_1616: not supported, BGR_565: not supported, RGBA_4444: not supported, RGBX_8888: not supported, RGBA_8888: not supported, BGRX_8888: not supported, BGRA_1010102: not supported, RGBA_1010102: not supported, BGRA_8888: not supported, RGBA_F16: not supported, YVU_420: not supported, YUV_420_BIPLANAR: not supported, YUVA_420_TRIPLANAR: not supported, P010: not supported
Compositor Information
Tile Update Mode
One-copy
Partial Raster
Enabled
GpuMemoryBuffers Status
R_8
Software only
R_16
Software only
RG_88
Software only
RG_1616
Software only
BGR_565
Software only
RGBA_4444
Software only
RGBX_8888
GPU_READ, SCANOUT
RGBA_8888
GPU_READ, SCANOUT
BGRX_8888
Software only
BGRA_1010102
Software only
RGBA_1010102
Software only
BGRA_8888
Software only
RGBA_F16
Software only
YVU_420
Software only
YUV_420_BIPLANAR
Software only
YUVA_420_TRIPLANAR
Software only
P010
Software only
Display(s) Information
Info
Display[2528732444] bounds=[0,0 1366x768], workarea=[0,0 1366x728], scale=1, rotation=0, panel_rotation=0 internal.
Color space (sRGB/no-alpha)
{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}
Buffer format (sRGB/no-alpha)
BGRX_8888
Color space (sRGB/alpha)
{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}
Buffer format (sRGB/alpha)
BGRA_8888
Color space (WCG/no-alpha)
{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}
Buffer format (WCG/no-alpha)
BGRX_8888
Color space (WCG/alpha)
{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}
Buffer format (WCG/alpha)
BGRA_8888
Color space (HDR/no-alpha)
{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}
Buffer format (HDR/no-alpha)
BGRX_8888
Color space (HDR/alpha)
{primaries:BT709, transfer:SRGB, matrix:RGB, range:FULL}
Buffer format (HDR/alpha)
BGRA_8888
Color volume
{name:'srgb', r:[0.6400, 0.3300], g:[0.3000, 0.6000], b:[0.1500, 0.3300], w:[0.3127, 0.3290]}
SDR white level in nits
203
HDR relative maximum luminance
1
Bits per color component
8
Bits per pixel
24
Refresh Rate in Hz
60
Video Acceleration Information
Decoding
Encoding
Vulkan Information
Device Performance Information
Total Physical Memory (Gb)
7
Total Disk Space (Gb)
0
Hardware Concurrency
4
System Commit Limit (Gb)
9
D3D11 Feature Level
Unknown
Has Discrete GPU
unknown
Software Rendering
No
Diagnostics
Driver Information for Hardware GPU
Initialization time
0
In-process GPU
true
Passthrough Command Decoder
true
Sandboxed
false
GPU0
VENDOR= 0x0000, DEVICE=0x0000, LUID={0,0}
Optimus
false
AMD switchable
false
Desktop compositing
Aero Glass
Direct composition
false
Supports overlays
false
YUY2 overlay support
NONE
NV12 overlay support
NONE
BGRA8 overlay support
NONE
RGB10A2 overlay support
NONE
Diagonal Monitor Size of \\.\DISPLAY1
15.5"
Driver D3D12 feature level
Not supported
Driver Vulkan API version
Not supported
GPU CUDA compute capability major version
0
Pixel shader version
Vertex shader version
Max. MSAA samples
Machine model name
Machine model version
GL implementation
disabled
ANGLE implementation
none
Display type
GL_VENDOR
Disabled
GL_RENDERER
Disabled
GL_VERSION
Disabled
GL_EXTENSIONS
Disabled Extensions
Disabled WebGL Extensions
Window system binding vendor
Window system binding version
Window system binding extensions
Direct rendering version
unknown
Reset notification strategy
0x0000
GPU process crash count
0
gfx::BufferFormats supported for allocation and texturing
R_8: not supported, R_16: not supported, RG_88: not supported, RG_1616: not supported, BGR_565: not supported, RGBA_4444: not supported, RGBX_8888: not supported, RGBA_8888: not supported, BGRX_8888: not supported, BGRA_1010102: not supported, RGBA_1010102: not supported, BGRA_8888: not supported, RGBA_F16: not supported, YVU_420: not supported, YUV_420_BIPLANAR: not supported, YUVA_420_TRIPLANAR: not supported, P010: not supported
Graphics Feature Status for Hardware GPU
Canvas: Software only. Hardware acceleration disabled
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Software only. Hardware acceleration disabled
Multiple Raster Threads: Disabled
OpenGL: Disabled
Rasterization: Software only. Hardware acceleration disabled
Raw Draw: Disabled
Video Decode: Software only. Hardware acceleration disabled
Video Encode: Software only. Hardware acceleration disabled
Vulkan: Disabled
WebGL: Disabled
WebGL2: Disabled
WebGPU: Disabled
Problems Detected for Hardware GPU
Gpu compositing has been disabled, either via blocklist, about:flags or the command line. The browser will fall back to software compositing and hardware acceleration will be unavailable.
Disabled Features: gpu_compositing
GPU process was unable to boot: GPU access is disabled through commandline switch --disable-gpu.
Disabled Features: all
Log Messages
Browser result from https://webglreport.com/?v=1
Desktop (PyQt6) result from https://webglreport.com/?v=1
it works for me. just use --use-gl=angle to override default --use-gl=disabled.
os.environ['QTWEBENGINE_CHROMIUM_FLAGS'] = '--use-gl=angle --gpu --gpu-launcher --in-process-gpu --ignore-gpu-blacklist --ignore-gpu-blocklist'
app = QApplication(sys.argv)