Qt WebEngine 出错:gpu_process_transport_factory.cc(642)] 切换到软件合成

Posted

技术标签:

【中文标题】Qt WebEngine 出错:gpu_process_transport_factory.cc(642)] 切换到软件合成【英文标题】:Error with Qt WebEngine : gpu_process_transport_factory.cc(642)] Switching to software compositing 【发布时间】:2019-11-25 23:54:13 【问题描述】:

背景

平台:windows 10 Qt 版本:5.12.1

我必须使用 QML QtWebKit 移植最初使用 Qt 4.7.4 完成的 QML 应用程序。这个 QML 非常简单,它只是显示一个本地 html。我阅读了this web page,了解如何迁移 QtWebKit。

所以,在尝试了几个小时后,我决定这样做qt example。

当我尝试执行应用程序时,我有这个输出:

[23912:5200:1125/182313.354:ERROR:gpu_process_transport_factory.cc(642)] Switching to software compositing.
[23912:5200:1125/182313.355:WARNING:gpu_process_transport_factory.cc(1007)] Lost UI shared context.
[23912:5836:1125/182313.911:WARNING:gpu_process_host.cc(583)] !GpuDataManagerImpl::GpuProcessStartAllowed()
[23912:5836:1125/182329.059:WARNING:gpu_process_host.cc(583)] !GpuDataManagerImpl::GpuProcessStartAllowed()
    知道我做错了什么吗? 是否可以坚持使用 QtWebKit? QtWebEngine 是呈现简单 html 用户指南的最佳解决方案吗?

我的 QtWebEngine 代码:

#include <QtGui/QGuiApplication>
#include <QTQml/QQmlApplicationEngine>
#include <QTWebEngine/qtwebengineglobal.h>

int main(int argc, char *argv[])

    QCoreApplication::setOrganizationName("QtExamples");
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
    QGuiApplication app(argc, argv);

    QQmlApplicationEngine engine;
    QtWebEngine::initialize();
    engine.load(QUrl(QStringLiteral("qrc:/test/Resources/main.qml")));

    return app.exec();

Qt WebEngine QML

import QtQuick 2.0
import QtQuick.Window 2.0
import QtWebEngine 1.0

Window 
    width: 1024
    height: 750
    visible: true
    WebEngineView 
        anchors.fill: parent
        url: "https://www.qt.io"
    


QtWebKit 代码

rootContext()->setContextProperty("uiDataLayer", pUiDataLayer);
setSource(QUrl("qrc:/SCmainWindow/Resources/userGuide.qml"));
QDeclarativeItem* item = qobject_cast<QDeclarativeItem*>(rootObject());

QtWebKit Qml

import QtQuick 1.1
import QtWebEngine 1.0

Rectangle 
    id: userGuide
    width: uiDataLayer.getUserGuideWindowWidth();
    height: uiDataLayer.getUserGuideWindowHeight();

    Flickable 
        id: flickableWebView
        anchors.fill: userGuide;
        contentWidth: webView.width
        contentHeight: webView.height
        interactive: true
        clip: true

        WebEngineView 
            id: webView
            url : "file:///C:/SVN/products/faa_mx/vs2017.install2/install/MSVC10.0.x86.debug/lexix_verbyx/bin/win32/Lexis-UG-1.0-00.html";
        
    


【问题讨论】:

@eyllanesc 是的,页面正在正确呈现。谢谢 【参考方案1】:

知道我做错了什么吗?

这些不是 Qt 的错误,而是 chromium 的错误,在许多情况下您必须忽略它们,在您的特定情况下表明应用程序尝试使用 GPU,但对于兼容性问题,它将使用 CPU(您应该得到那些如果您从 CMD 运行 google chrome 并启用标志以获取调试,则会出现同样的错误。

所以请避免这些错误,因为您提供的代码是正确的。

是否可以坚持使用 QtWebKit?

您可以继续使用 Qt WebKit,但没有来自 Qt 的官方支持,您必须手动编译它。该项目托管在https://github.com/qtwebkit/qtwebkit。

QtWebEngine 是呈现简单 html 用户指南的最佳解决方案吗?

“最佳”是相对的,除非您指明客观参数,以便您在每种技术/替代方案中衡量自己。我可以给大家指出的是,使用HTML、js等渲染网页、html等是官方的选项。

【讨论】:

以上是关于Qt WebEngine 出错:gpu_process_transport_factory.cc(642)] 切换到软件合成的主要内容,如果未能解决你的问题,请参考以下文章

项目错误:QT 中的未知模块:webengine

Yocto SDK,QtWebEngine:QT 中的未知模块:webengine

如何单击 Qt WebEngine 中的按钮?

QT学习-核心类列表-3Qt WebEngine Widgets

Qt5.9.1 和 Visual Studio 2015 添加 Qt WebEngine 模块

QT WebEngine 和 JavaScript 无法加载 .PNG 图像