QT webkit Access Violation Could not initialize egl display: error 12289 when invoked in service or IIS on one website
-
I build a console app with QT 5.1, msvc 64 bit, console app. It is invoked from asp.net website or a windows service (running as admin) on windows 8 64 bit version.
EDIT: checking the source, the error 12289 is EGL_NOT_INITIALIZED, looks like the display render initialization failed. Anyone got any quick pointers?
All it does is load up some webpage, and it works fine on all webpages except one.
http://search.sunbiz.org/On that page it exits with -1073741819 (access violation) and stderr has this:
class QWindowsEGLStaticContext *__cdecl QWindowsEGLStaticContext::create(void): Could not initialize egl display: error 12289It runs fine when I run it in console. when it is invoked via IIS or service, it runs fine on all other websites except the one mentioned above.
Code is attached:
Header@#ifndef HEADER1_H
#define HEADER1_H#include <QtWebKit>
#include <QtCore>
#include <QWebPage>
#include <QAtomicInt>
#include <QAuthenticator>
#include <QFile>
#include <QFileInfo>
#include <QNetworkAccessManager>
#include <QNetworkCookieJar>
#include <QNetworkReply>
#include <QWebFrame>
#include <QProxyStyle>
#include <QApplication>class DManager: public QObject {
Q_OBJECT
private:
QNetworkAccessManager networkAccessManager;
public:
DManager();
QWebPage webPage;
public slots:
void load();
void loadProgress(int progress);void warning(const QString & str); void error(const QString & str); void loadFinished(bool ok);
};
class MyProxyStyle : public QProxyStyle
{
public:
int styleHint(StyleHint hint, const QStyleOption *option = 0,
const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const
{
if (hint == QStyle::SH_UnderlineShortcut)
return 0;
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
};#endif // HEADER1_H
@Body:
@#include <QApplication>
#include <QProxyStyle>
#include <QPrintEngine>
#include <QLocalSocket>
#include "header.h"DManager::DManager() :networkAccessManager(this)
{
connect(&webPage, SIGNAL(loadProgress(int)), this, SLOT(loadProgress(int)));
connect(&webPage, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));webPage.setNetworkAccessManager(&networkAccessManager);
}
void DManager::load(){
QNetworkRequest r = QNetworkRequest(QString("http://search.sunbiz.org/"));
webPage.mainFrame()->load(r);}
void DManager::loadFinished(bool ok) {
qApp->exit(0);
}void DManager::loadProgress(int p) {
printf("load prog %i\n", p);
FILE * fp = fopen("c:\temp\fopen.txt","a");
fprintf(fp,"load prog %i\n",p);
fclose(fp);
}void DManager::warning(const QString & str) {
FILE * fp = fopen("c:\temp\fopen.txt","a");
fprintf(fp,"error %s", (const char*)str.toLatin1()) ;
fclose(fp);
}void DManager::error(const QString & str) {
FILE * fp = fopen("c:\temp\fopen.txt","a");
fprintf(fp,"error %s", (const char*)str.toLatin1()) ;
fclose(fp);
}int main(int argc, char *argv[])
{
FILE * fp = fopen("c:\temp\fopen.txt","w");
fprintf(fp, "start v0.6\n");
fclose(fp);
QApplication a(argc, argv);
a.setStyle(new MyProxyStyle());DManager *res = new DManager(); printf("loading\n"); res->load(); int result = a.exec(); return result;
}
@Project:
@
QT += core network webkit webkitwidgets concurrentQT += gui
TARGET = test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = app
SOURCES += main.cpp
HEADERS += header.h
@Code (in c#) to invoke the app (must run under iis or service)
@
var name = @"c:\temp\qtweb\release\test.exe";
var proc = Process.Start(new ProcessStartInfo(name)
{
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardError = true,
RedirectStandardOutput = true,
CreateNoWindow = true,
});
var stdout = proc.StandardOutput.ReadToEndAsync();
var stderr = proc.StandardError.ReadToEndAsync().Result;bool ext = proc.WaitForExit(30000); File.WriteAllText(@"c:\temp\test.txt", stderr + "\r\n stdout=" + stdout.Result + "\r\n" + proc.ExitCode + "\r\n"+ext);
@
Other steps:
The website/service are running as admin account. I copied all dlls under [QT]\Qt5.1.0\5.1.0\msvc2012_64\bin
to the app directory, and copied everything under [QT]\Qt5.1.0\5.1.0\msvc2012_64\plugins\platforms to platforms in app directory (structure:app
dlls
platforms/xxx)By default all output went to c:\temp folder.
Please help.
Thanks
GZ -
You say that's console app yet you include
QtWebKit
QWebFrame
QApplication instead of QCoreApplicationThat doesn't look like console application to me
any of these could attempt to create a widget that will lead to... oh actually it is Webkit complaining: "QT webkit Access Violation"
so either use networkAccessManager only and forget about WebKit
or make it a GUI application.You can not create GUI components aka widgets in a windowless aka console application - you have to provide graphical interface somehow:
on linux you could do this "how to use Qt webkit in command line interface":http://qt-project.org/forums/viewthread/29671/ -
Well your other option is:
"Qt-5-on-Windows-ANGLE-and-OpenGL":http://qt-project.org/wiki/Qt-5-on-Windows-ANGLE-and-OpenGL..and read carefully deployment section(s)