Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72816

Crash in QWebEnginePage runJavaScript callback

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.12.0
    • WebEngine
    • None
    • All

    Description

      Sometimes the pointer to the QWebEngineView inside the QWebEnginePage::runJavaScript callback is undefined. This behavior occurs when the JavaScript is running longer than the QWebEngineView lives. To reproduce, execute an endless loop in the JavaScript callback and than delete the QWebEngineView i.e. by closing the tab. By deleting the view, the JavaScript is aborted and the callback is triggered.

      QWebEngineView* v = new QWebEngineView();
        v->page()->runJavaScript("while(true){}",
           QWebEngineScript::ApplicationWorld,
            [v](const QVariant& data)

      {           v->page(); // seg fault because "v" is invalid       }

        );

      For me this is unexpected, because the JavaScript lives inside the page and the page inside the WebEngineView.

      Perhaps it is possible to introduce a similer concept like in the connect function of Qt. The connect function ensures that the sender and receiver are alive when the callback is triggered.

      connect(sender, &Sender::valueChanged, receiver, &Receiver::updateValue );

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt_webengine_team Qt WebEngine Team
            schaef Christoph Schaefer
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes