Qt QWebEngine 远程调试:Chrome 开发人员工具不再有效
Qt QWebEngine Remote Debugging: Chrome developer tools no longer work
最近在一些软件更新后(自动 Windows 10 更新,可能还有 Chrome 自动更新),用于从 Qt 的 QWebEngine 进行远程调试的开发人员工具停止工作。 JavaScript 控制台显示:
Uncaught TypeError: document.registerElement is not a function
at Object.UI.registerCustomElement (shell.js:formatted:18064)
at shell.js:formatted:18178
at shell.js:formatted:18266
devtools_app.js:formatted:2606 Uncaught ReferenceError: SDK is not defined
at devtools_app.js:formatted:2606
有问题的代码(来自 shell.js)是这样的:
UI.registerCustomElement = function(localName, typeExtension, prototype) {
return document.registerElement(typeExtension, {
prototype: Object.create(prototype),
extends: localName
});
}
什么是 shell.js,它来自哪里?这个问题的原因可能是什么?
该网页实际上是 运行 在 Qt 5.12.3 网络浏览器中,但我正在使用 Chrome(远程)开发人员工具。
我也同时升级了Angular7.x到Angular8,但不再相信这有关系。
我的 Chrome 当前版本为 80.0.3987.116(正式版)(64 位)。
更新
我刚刚尝试下载旧版本的 Chromium。 (我尝试了版本 77.0.3823.0,因为这可以追溯到 2019 年年中。)并在那里进行调试。
Google 从 Chrome 中删除了 WebComponents V0,但用于远程调试的 GUI 使用它们。
因此,当您尝试在板载旧 Chrome 的设备上启动远程调试时 - 调试器崩溃
Uncaught TypeError: document.registerElement is not a function
我找到了两种解决方法
- 降级 Chrome 并且没有简单的方法(如果您在此处使用 mac link https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/668249/)
- 在目标设备上升级 chrome,在大多数情况下是不可能的(
Chrome 80 已弃用这些开发工具使用的 WebComponents v0。
解决方案是使用额外参数启动 Chrome 以重新启用该功能(当它仍在引擎中时):
--enable-blink-features=ShadowDOMV0,CustomElementsV0
或者使用对应 Chrome 79.x 的 Chromium 版本,例如
Windows: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/706915/
Mac: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/706915/
Linux: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/706915/
参见:
最近在一些软件更新后(自动 Windows 10 更新,可能还有 Chrome 自动更新),用于从 Qt 的 QWebEngine 进行远程调试的开发人员工具停止工作。 JavaScript 控制台显示:
Uncaught TypeError: document.registerElement is not a function
at Object.UI.registerCustomElement (shell.js:formatted:18064)
at shell.js:formatted:18178
at shell.js:formatted:18266
devtools_app.js:formatted:2606 Uncaught ReferenceError: SDK is not defined
at devtools_app.js:formatted:2606
有问题的代码(来自 shell.js)是这样的:
UI.registerCustomElement = function(localName, typeExtension, prototype) {
return document.registerElement(typeExtension, {
prototype: Object.create(prototype),
extends: localName
});
}
什么是 shell.js,它来自哪里?这个问题的原因可能是什么?
该网页实际上是 运行 在 Qt 5.12.3 网络浏览器中,但我正在使用 Chrome(远程)开发人员工具。
我也同时升级了Angular7.x到Angular8,但不再相信这有关系。
我的 Chrome 当前版本为 80.0.3987.116(正式版)(64 位)。
更新 我刚刚尝试下载旧版本的 Chromium。 (我尝试了版本 77.0.3823.0,因为这可以追溯到 2019 年年中。)并在那里进行调试。
Google 从 Chrome 中删除了 WebComponents V0,但用于远程调试的 GUI 使用它们。 因此,当您尝试在板载旧 Chrome 的设备上启动远程调试时 - 调试器崩溃
Uncaught TypeError: document.registerElement is not a function
我找到了两种解决方法
- 降级 Chrome 并且没有简单的方法(如果您在此处使用 mac link https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/668249/)
- 在目标设备上升级 chrome,在大多数情况下是不可能的(
Chrome 80 已弃用这些开发工具使用的 WebComponents v0。
解决方案是使用额外参数启动 Chrome 以重新启用该功能(当它仍在引擎中时):
--enable-blink-features=ShadowDOMV0,CustomElementsV0
或者使用对应 Chrome 79.x 的 Chromium 版本,例如
Windows: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/706915/
Mac: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/706915/
Linux: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Linux_x64/706915/
参见: