PDA

View Full Version : How to avoid qtwebengine to crash main program?



qtcentre2019
21st April 2019, 14:10
I load many urls in a QWebEngineView object, one by one. Some urls are displayed normally, some will make my app crash. I do not know if it is a Qt problem or chromium problem. But can I avoid qtwebengine to crash main program so I can continue to load the following urls? It should be something like:


for(i=0;i<100;i++)
{
try
{
view->load(urls[i]);
}
catch(...)
{
}
}

But since QWebEngineView::load is an asynchronous function, I could not use the above code to ignore the failed url.

anda_skoa
21st April 2019, 15:03
Some urls are displayed normally, some will make my app crash.

Do you have an example?



But since QWebEngineView::load is an asynchronous function

Even if it were synchronous you would only be seeing the last URL.

And a crash is not necessarily caused by an uncaught exception, a crash can be triggered by a lot of things.

Cheers,
_

qtcentre2019
22nd April 2019, 10:35
@anda_skoa
Yes, there may be many reasons for the crash so I do not plan to dig the actual reason out. I just want to bypass the failed url and go to the next url. It seems all chromium stuff are run in QtWebEngineProcess.exe? If so, why the bug in chromium does not only crash QtWebEngineProcess.exe, but main program? If the crash is not caused by an exception, can I ignore the error and continue the execution of main program like what's done by try..catch? I really do not want to head into the QtWebEngine code to sort it out.


Do you have an example?


Even if it were synchronous you would only be seeing the last URL.

And a crash is not necessarily caused by an uncaught exception, a crash can be triggered by a lot of things.

Cheers,
_

anda_skoa
22nd April 2019, 11:15
It seems all chromium stuff are run in QtWebEngineProcess.exe?

Yes



If so, why the bug in chromium does not only crash QtWebEngineProcess.exe, but main program?

Have you determined that it is a bug in chromium?
I.e. does the stack trace of the crash end in Chromium code?



If the crash is not caused by an exception, can I ignore the error and continue the execution of main program like what's done by try..catch?

A crash means the process reached an unrecoverable state.
The operating system has no other means than to end it.

If a crash can not be fixed you can only isolate it, i.e. running the crashing code in a separate process.

And just to be sure: you need to display all these pages, right?

I.e. the reason you are not using QNetworkAccessManager is because you need the web content rendered on screen, correct?

Cheers,
_