Flickering of webengineview when showing webGL content AND having an secondary screen attached
-
I implement an application based on pyqt6 with a webengine view which shows a web page with webgl content. I noticed that a quite weird bug:
When I connect a secondary screen to the laptop, and only then, in an unpredictable fashion, the webengineview content starts and stops to flicker.OS: Windows 11
pyqt version: 6.6.1
pyqt6-webengine: 6.6.0Hardware:
- Lenovo Ideapad 330 with secondary screen attached (important!)
- CPU: Intel i5 8250U
- GPU: Intel UHD Graphics 620
Example code:
#!/usr/bin/env python # -*- coding: utf-8 -*- """ WebGL Windows Flickering example, stripped down from original application Hardware: * Lenovo Ideapad 330 with secondary screen attached (important!) * CPU: Intel i5 8250U * GPU: Intel UHD Graphics 620 """ import sys from PyQt6.QtCore import QUrl from PyQt6.QtWebEngineWidgets import QWebEngineView from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout class MainWindow(QMainWindow): def __init__(self): super().__init__() wgt_main = QWidget() self.layout_main = QVBoxLayout() wgt_main.setLayout(self.layout_main) self.setCentralWidget(wgt_main) self.wbv_main = QWebEngineView() self.wbv_main.load(QUrl("https://threejs.org/examples/#webgl_animation_keyframes")) self.wbv_main.show() self.layout_main.addWidget(self.wbv_main) self.showMaximized() if __name__ == "__main__": # Start QT app app = QApplication(sys.argv) window = MainWindow() window.show() app.exec()
If I open the same web page with Chrome, I do not get any flickering at all.
The bug does not show up on Ubuntu or if no secondary screen is attached.Can anybody make sense of this?
-
self.showMaximized()Put it in front,
Because the initial window is small, flickering is when the window suddenly maximizes
from PyQt6.QtCore import QUrl
from PyQt6.QtWebEngineWidgets import QWebEngineView
from PyQt6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayoutclass MainWindow(QMainWindow):
def init(self):
super().init()
self.showMaximized()
wgt_main = QWidget()
self.layout_main = QVBoxLayout()
wgt_main.setLayout(self.layout_main)
self.setCentralWidget(wgt_main)self.wbv_main = QWebEngineView() self.wbv_main.load(QUrl("https://threejs.org/examples/#webgl_animation_keyframes")) self.wbv_main.show() self.layout_main.addWidget(self.wbv_main)
if name == "main":
# Start QT app
app = QApplication(sys.argv)window = MainWindow() window.show() app.exec()