Results 1 to 2 of 2

Thread: QWebEngineView + QPropertyAnimation make animation very slow

  1. #1
    Join Date
    Aug 2021
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  2. #2
    Join Date
    Aug 2021
    Posts
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

    sandbox_webview_qpropertyanimation.png

    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 :
    Qt Code:
    1. class AnimationBarItem : public QObject, public QGraphicsRectItem
    2. {
    3. Q_OBJECT
    4. Q_PROPERTY(QRectF rect READ rect WRITE setRect)
    5. ...
    6. }
    7. class AnimationBar : public QGraphicsView
    8. {
    9. Q_OBJECT
    10. ...
    11. AnimationBarItem *bar = nullptr;
    12. }
    13.  
    14. void AnimationBar::setPourcent(qreal pourc){
    15. QPropertyAnimation *animation = new QPropertyAnimation(bar, "rect");
    16. animation->setDuration(200);
    17. animation->setStartValue(QRect(0, 0, 0, mH));
    18. animation->setEndValue(QRect(0, 0, ww,mH));
    19. animation->start();
    20. }
    To copy to clipboard, switch view to plain text mode 
    2. The QWebEngineView is created as follow :
    Qt Code:
    1. mWebEngineView = new QWebEngineView();//can't link to this, for compatibility with my project
    2. mWebEnginePage = new QWebEnginePage(mWebEngineView);
    3. mWebEnginePage->setView(mWebEngineView);
    4. mWebEngineView->setUrl(QUrl("http://www.google.com"));
    To copy to clipboard, switch view to plain text mode 
    3. then add in QMainWindow with method :
    Qt Code:
    1. mLayoutForBrowse=new QVBoxLayout(ui->ZONE_webview);
    2. mLayoutForBrowse->addWidget(mWebEngineView);
    To copy to clipboard, switch view to plain text mode 
    4. Or, in a new QMainWindow :
    <br>And not in the same QMainWindow like previous point, with :
    Qt Code:
    1. this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 
    5. killing webview :
    Qt Code:
    1. void MainWindow::killWebView(bool is){
    2. if (mWebEngineView!=nullptr) mWebEngineView->stop();
    3. mWebEngineView->deleteLater();
    4. mLayoutForBrowse->deleteLater();
    5. mWebEnginePage->deleteLater();
    6. mWebEngineView=nullptr;
    7. mLayoutForBrowse=nullptr;
    8. mWebEnginePage=nullptr;
    9. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to make preview QWebEngineView before printing?
    By Jacek.J in forum Qt Programming
    Replies: 0
    Last Post: 2nd February 2017, 08:51
  2. Replies: 2
    Last Post: 21st February 2012, 12:13
  3. QPropertyAnimation show the Widget before start the animation
    By rperezalejo in forum Qt Programming
    Replies: 0
    Last Post: 13th October 2011, 03:26
  4. QPropertyAnimation and animation speed
    By themk in forum Qt Programming
    Replies: 0
    Last Post: 13th October 2010, 01:05
  5. Replies: 0
    Last Post: 8th April 2010, 10:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.