QWebEngineView + QPropertyAnimation make animation very slow
Hello,
With 2 os, win10/Qt5.15.2 or Mac/Qt5.15.0, if I create a QPropertyAnimation, and in the same time I use a QWebEngineView (and kill it or not), then animations become very slow.
If I embed the QWebEngineView in an external window (this new windows in front of the main window), then animations are fluid.
I prefer do not externalise QWebEngineView , this is not the right way.
sources (>Qt5.10): https://media.nperf.com/files/misc/s..._animation.zip
This problem seams solved on ubuntu20/Qt5.12 and ubuntu18/Qt5.9.2, but not in win10/Qt5.15.2 nor Mac/Qt5.15.0
Is there a way to avoid QWebEngineView externalization ? May be killing properly QWebEngineView?
Thanks for your help.
1 Attachment(s)
Re: QWebEngineView + QPropertyAnimation make animation very slow
Trying to explain my problem with more details.
I have a problem with QPropertyAnimation when QWebEngineView is used in the same QMainWindow.
If I create 15 QPropertyAnimation (animate QGraphicsRectItem),
and in the same time I use a QWebEngineView, then animations become very slow.
I have created a demo (to compile yourself), with minimum usefull source code : https://media.nperf.com/files/misc/s..._animation.zip
Attachment 13723
Tests made with one QMainWindow :
After creating QWebEngineView, if I kill it, the problem continues.
If I use QTimer loop instead of QPropertyAnimation, the problem is the same.
Tests made with two QMainWindow :
If I embed the QWebEngineView in an external window (new QMainWindow), then animations become smooth again.
This new QMainWindow is not the same QMainWindow where QPropertyAnimations are running.
However, this is not an acceptable solution for me, but this shows that there is a resource that is shared between QWebEngineView and QPropertyAnimations,
if and only if the QWebEngineView was created in the same QMainWindow.
So I wonder :
- Did I kill the QWebEngineView correctly ?
- Is there a way to seperate QWebEngineView threads from QMainWindow ?
- Or any other solution...
Environment context :
This problem exist with two environments, win10/Qt5.15.2 and Mac/Qt5.15.0.
But does not exist with ubuntu20/Qt5.12 and ubuntu18/Qt5.9.2.
Reproductible code example (Code description of demo shared):
1. The QPropertyAnimation change size of a QGraphicsRectItem :
Code:
{
Q_OBJECT
Q_PROPERTY(QRectF rect READ rect WRITE setRect
) ...
}
{
Q_OBJECT
...
AnimationBarItem *bar = nullptr;
}
void AnimationBar::setPourcent(qreal pourc){
QPropertyAnimation *animation = new QPropertyAnimation(bar, "rect");
animation->setDuration(200);
animation
->setStartValue
(QRect(0,
0,
0, mH
));
animation
->setEndValue
(QRect(0,
0, ww,mH
));
animation->start();
}
2. The QWebEngineView is created as follow :
Code:
mWebEngineView = new QWebEngineView();//can't link to this, for compatibility with my project
mWebEnginePage = new QWebEnginePage(mWebEngineView);
mWebEnginePage->setView(mWebEngineView);
mWebEngineView
->setUrl
(QUrl("http://www.google.com"));
3. then add in QMainWindow with method :
Code:
mLayoutForBrowse->addWidget(mWebEngineView);
4. Or, in a new QMainWindow :
<br>And not in the same QMainWindow like previous point, with :
Code:
this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
5. killing webview :
Code:
void MainWindow::killWebView(bool is){
if (mWebEngineView!=nullptr) mWebEngineView->stop();
mWebEngineView->deleteLater();
mLayoutForBrowse->deleteLater();
mWebEnginePage->deleteLater();
mWebEngineView=nullptr;
mLayoutForBrowse=nullptr;
mWebEnginePage=nullptr;
}