2

I get the following error if I create a QWebEngineView instance from Python instances in different working directories:

[2452:9872:1108/052617.050:ERROR:cache_util_win.cc(21)] Unable to move the cache: Access is denied. (0x5)
[2452:9872:1108/052617.050:ERROR:cache_util.cc(135)] Unable to move cache folder C:\Users\Adam\AppData\Local\python\QtWebEngine\Default\GPUCache to C:\Users\Adam\AppData\Local\python\QtWebEngine\Default\old_GPUCache_000
[2452:9872:1108/052617.051:ERROR:disk_cache.cc(184)] Unable to create cache
[2452:9872:1108/052617.056:ERROR:shader_disk_cache.cc(606)] Shader Cache Creation failed: -2
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
from PyQt5.QtCore import Qt
app = QtWidgets.QApplication([])
x = QtWebEngineWidgets.QWebEngineView()
x.load(QtCore.QUrl('http://example.com/'))

enter image description here

It seems this is a known issue and will be fixed in QT6: https://bugreports.qt.io/browse/QTBUG-66014

But in the meantime, how can I suppress this message? I tried changing QtCore.qInstallMessageHandler and also x.page().javaScriptConsoleMessage = lambda self, level, msg, line, sourceID: None, neither affected this message.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
pyjamas
  • 4,608
  • 5
  • 38
  • 70
  • try add `import os` `os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--disable-logging"` before `app = QtWidgets.QApplication([])` – eyllanesc Nov 08 '20 at 13:59
  • @eyllanesc Still get the same message https://www.screencast.com/t/rHeWHPoGvG – pyjamas Nov 08 '20 at 15:59
  • @eyllanesc I tried some other flags and tried passing flags straight to the app (https://pastebin.com/kcw4Tfwt), but none of the flags seem to have any effect, it seems like they're not getting applied to the QWebEngineView... Do you have any other ideas? – pyjamas Nov 08 '20 at 22:30
  • 1
    try with: `os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--enable-logging --log-level=3"` – eyllanesc Nov 08 '20 at 22:38
  • Yes, that one works! I guess a lot of flags aren't supported but --log-level is. Thanks once again @eyllanesc :) – pyjamas Nov 08 '20 at 22:44

1 Answers1

3

One possible solution is to raise the level of the chromium log:

import os
from PyQt5 import QtCore, QtGui, QtWidgets, QtWebEngineWidgets

os.environ["QTWEBENGINE_CHROMIUM_FLAGS"] = "--enable-logging --log-level=3"
app = QtWidgets.QApplication([])
x = QtWebEngineWidgets.QWebEngineView()
# ...
eyllanesc
  • 235,170
  • 19
  • 170
  • 241