Page 1 of 2 12 LastLast
Results 1 to 20 of 21

Thread: window freeze

  1. #1
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question window freeze

    What would be the best way to prevent a window freeze the other windows?

    I tried to move my QMainWindow to a thread (QMainWindow::moveToThread), but this is not possible for the widgets can not be moved.

    I'd like to open a new window in a separate process.

    The reason is that if this new page has a script to freeze the window he ends up freezing all other windows.

    Qt Code:
    1. class myWebPage : public QWebPage {
    2. QWebPage * createWindow(QWebPage::WebWindowType type) {
    3. Q_UNUSED(type);
    4. QMainWindow *wx = new mBROWSERQT(NULL,true);
    5. QWebView *wv = wx->findChild<QWebView*>("mybrowsertest");
    6.  
    7. wx->showNormal();
    8. return wv->page();
    9. }
    10. };
    11.  
    12. ...
    13.  
    14. ui->mybrowsertest->setPage(new myWebPage());
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    JavaScript inside a webview shouldn't freeze anything. You can subclass QWebPage and reimplement shouldInterruptJavaScript() if you want however this is not exactly what you want.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    brcontainer (17th May 2013)

  4. #3
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: window freeze

    Quote Originally Posted by wysota View Post
    JavaScript inside a webview shouldn't freeze anything. You can subclass QWebPage and reimplement shouldInterruptJavaScript() if you want however this is not exactly what you want.
    thanks for the reply.

    But not only is the javascript that froze the windows,
    there are ways to freeze up window with PHP/.net/jsp.

    Is there any way I can pass variables and commands a QWebView in a program to another QWebView in another program?

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    Quote Originally Posted by brcontainer View Post
    there are ways to freeze up window with PHP/.net/jsp.
    Those languages run on server side and not on the client. I don't see how this relates to your problem.

    Is there any way I can pass variables and commands a QWebView in a program to another QWebView in another program?
    You can do anything you want if you implement it. There are several IPC methods available in computer world. If you teach both programs to use them then you can pass information between different programs.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    brcontainer (17th May 2013)

  7. #5
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: window freeze

    Thanks again for your quick response.

    Quote Originally Posted by wysota View Post
    You can do anything you want if you implement it. There are several IPC methods available in computer world. If you teach both programs to use them then you can pass information between different programs.
    I had read about IPC, but I'm having trouble reimplement createWindow.

    An example of this is that I also tried Qfuture::run", however when passing the QWebpage for createWindow he hangs anyway. I believe I have to reimplement createWindow with Qfuture.

    How could I reimplement createWindow (or QWebPage, QWebFrame, etc.) with functions like Thread (To do something like the thread) ?

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    I have no idea what you are trying to do. Why do you wish to reimplement createWindow()?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #7
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: window freeze

    Thanks for the help and the quick response.

    I have no idea what you are trying to do. Why do you wish to reimplement createWindow()?
    Every time I click an anchor with target="_blank" (or run the window.open) the QWebPage performing QWebPage::createWindow.

    The QWebPage::createWindow need to get the new QWebPage who will receive the target="_blank" (or target="name").

    But to send to send a page that can freeze, it also ends up freezing the window PARENT and other windows created by QWebPage::createWindow.

    I need to isolate the QWebPage but without affecting the functionality of the targets, window.opener and parent.window.

    The only browser I've seen that works this way is the Google Chrome, if one tab has a Javascript that cause freezing, only the tab (or window) freezes, the other tabs work normally (the other tabs and windows do not freeze).
    Last edited by brcontainer; 17th May 2013 at 15:42. Reason: improved

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    createWindow() returns a QWebView and not QWebPage.

    Chrome does out-of-process handling of web pages thus if one page locks the whole process, other pages can continue because they have their own processes.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #9
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: window freeze

    Thanks again for the quick response.

    Quote Originally Posted by wysota View Post
    createWindow() returns a QWebView and not QWebPage.
    both QWebVieW as Qwebpage has createWindow ( http://qt-project.org/doc/qt-4.8/qwe...cted-functions )

    Example:
    Qt Code:
    1. class myWebPage : public QWebPage {
    2. protected:
    3. virtual QString userAgentForUrl(const QUrl & url) const {
    4. Q_UNUSED(url);
    5. return UA;
    6. }
    7.  
    8. QWebPage * createWindow(QWebPage::WebWindowType type) {
    9. return new QWebPage;
    10. }
    11. };
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by wysota View Post
    Chrome does out-of-process handling of web pages thus if one page locks the whole process, other pages can continue because they have their own processes.
    I know that, but I just used it as an example for you to understand. I wonder if it has something to do with Qt?

    Could you help me with this? Thanks
    Last edited by brcontainer; 17th May 2013 at 17:57.

  12. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    If you state your problem clearly then maybe someone can help. As I said, JavaScript alone will not freeze your browser as it is periodically interrupted so that the browser can process its events. When QtWebKit detects a long running script, it will pop up a window asking whether you want to abort the script or not.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #11
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: window freeze

    Quote Originally Posted by wysota View Post
    If you state your problem clearly then maybe someone can help. As I said, JavaScript alone will not freeze your browser as it is periodically interrupted so that the browser can process its events. When QtWebKit detects a long running script, it will pop up a window asking whether you want to abort the script or not.
    test my app (open-source QT5):
    http://www.mediafire.com/download.php?85zm06bvwv9lyow

    Note that clicking on anchor test Freeze all application windows freeze.

    I need the window open for anchor "test Freeze" freezes and that the other windows continue to work normally (without freezing).

    I wonder if you could help me?
    Thanks.

  14. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. #13
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: window freeze

    Quote Originally Posted by wysota View Post
    Hello @wysota
    I appreciate your attempt to help me, but it does have to do with my question.

    And I'm not the problem JavaScript engine, I just want to separate the "QWebView" into something like multi-processes (eg. QFuture, QThread, etc.).

    I'll try to be more simple and clear in the question:
    How to separate the QWebView (or QwebPage, QWebFrame, etc.) into something like multi-processes (eg. QFuture, QThread, etc.)?

  16. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    Quote Originally Posted by brcontainer View Post
    And I'm not the problem JavaScript engine, I just want to separate the "QWebView" into something like multi-processes (eg. QFuture, QThread, etc.).
    QFuture and QThread have nothing to do with multi-processing. If you want multiprocessing then you need to implement a master process that will act as a container for all the pages and you need to implement the slave that will let itself be embedded into the master process. There is nothing in Qt that can help you with that directly. It is not something that you can do in 10 minutes. If you want, have a look at Chromium sources.

    Edit: here is something that might help you: http://blog.chromium.org/2008/09/mul...hitecture.html
    Last edited by wysota; 18th May 2013 at 15:20.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #15
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: window freeze

    Quote Originally Posted by wysota View Post
    QFuture and QThread have nothing to do with multi-processing. If you want multiprocessing then you need to implement a master process that will act as a container for all the pages and you need to implement the slave that will let itself be embedded into the master process. There is nothing in Qt that can help you with that directly. It is not something that you can do in 10 minutes. If you want, have a look at Chromium sources.
    I could use QFuture with QWebPage::acceptNavigationRequest, the problem is that I want to do this with QWebPage::createWindow, but I do not know how to "rewrite" the QWebPage::createWindow to work with QFuture.

    See what I got:
    Qt Code:
    1. class myWebPage : public QWebPage
    2. {
    3. QWebPage *p;
    4. void Test(const QUrl & url){
    5. QWebView *p = new QWebView;
    6. p->show();
    7. p->setUrl(url);
    8. }
    9.  
    10. bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) {
    11. QUrl url = request.url();
    12. if(parentFrame==false){
    13. firstFrame = frame;
    14. parentFrame = true;
    15. } else {
    16. if(frame != firstFrame){
    17. QtConcurrent::run(this,&myWebPage::Teste,url);
    18. }
    19. }
    20. return QWebPage::acceptNavigationRequest(frame,request,type);
    21. }
    22. };
    To copy to clipboard, switch view to plain text mode 

    This code works with target="" but does not work with window.open, so I need to understand how to rewrite the QWebPage::createWindow

    Could you help me with this?

  18. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    Quote Originally Posted by brcontainer View Post
    I could use QFuture with QWebPage::acceptNavigationRequest, the problem is that I want to do this with QWebPage::createWindow, but I do not know how to "rewrite" the QWebPage::createWindow to work with QFuture.
    It won't work because all GUI-related work has to be done in the same thread. Thus QWebPage and its related QWebView have to live in the same thread and QWebView and all the other webviews have to live in the same thread. Thus all pages and all views have to live in the same thread. Hence freezing one will freeze them all. Multiprocessing is the only possible solution here and as I already said this can't be done by reimplementing one or two virtual methods here and there.

    I'm afraid fixing the bug I mentioned and which you said did not relate to your problem is your only possible solution now short of reimplementing Chromium
    Last edited by wysota; 18th May 2013 at 22:01.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  19. #17
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: window freeze

    I thought of two things

    1 - if I'm not mistaken some modern platforms have "Dbus", there is something for Windows (or better crossplatform)?
    2 - Is there any project "Chromium+QT" that does not require the "cygwin"?

    Thanks.

  20. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    Quote Originally Posted by brcontainer View Post
    1 - if I'm not mistaken some modern platforms have "Dbus", there is something for Windows (or better crossplatform)?
    I don't see how that's helpful to you. There are multiple IPC mechanisms that you can use such as local sockets or shared memory and they suit the situation much better because d-bus doesn't provide any security and I doubt you'd want someone to tamper with your browser slaves.

    2 - Is there any project "Chromium+QT" that does not require the "cygwin"?
    I don't think chromium requires cygwin. Qt has nothing to do with this since Chromium is not based on Qt.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  21. #19
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question Re: window freeze

    Quote Originally Posted by wysota View Post
    I don't see how that's helpful to you. There are multiple IPC mechanisms that you can use such as local sockets or shared memory and they suit the situation much better because d-bus doesn't provide any security and I doubt you'd want someone to tamper with your browser slaves.
    sorry my english is that sometimes fails, I meant something like dbus.

    How could I use Socket or SharedMemory with QWebPage::createWindow?


    Quote Originally Posted by wysota View Post
    I don't think chromium requires cygwin. Qt has nothing to do with this since Chromium is not based on Qt.
    You're right, cygwin is optional, failure was in my reading. About "QT + Chromium", what I mean is if there is some project ported to QT that use Chromium (but so googled there is nothing like that).


    Unfortunately I am losing hope of creating an efficient application.
    Thanks.

  22. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: window freeze

    Quote Originally Posted by brcontainer View Post
    How could I use Socket or SharedMemory with QWebPage::createWindow?
    You couldn't. And if you keep going back to that method, you won't be making any progress. createWindow itself will not help you prevent freezing web browser windows.

    what I mean is if there is some project ported to QT that use Chromium (but so googled there is nothing like that).
    Using Chromium itself doesn't make much sense, it is probably too bloated for you anyway. You could probably make some use of Chromium Embedded Framework (https://code.google.com/p/chromiumembedded/) but that gives you a complete browser environment that you have no influence on.

    Unfortunately I am losing hope of creating an efficient application.
    As I said, this task can't be done in 10 minutes of coding.

    Here is what Chromium does more or less:
    http://www.chromium.org/developers/d...s-architecture

    You can probably come up with a solution that implements a similar architecture but again -- not in 10 minutes of coding.

    Here is a general description of IPC they use:

    http://www.chromium.org/developers/d...-communication
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QSerialDevice cause GUI to freeze
    By dkoryagin in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2010, 17:13
  2. window refresh freeze
    By jhowland in forum Qt Programming
    Replies: 1
    Last Post: 22nd February 2010, 07:58
  3. Thread,GUI Freeze
    By darshan in forum Qt Programming
    Replies: 2
    Last Post: 25th February 2009, 20:17
  4. Qt4.2.2: Application freeze
    By arunvv in forum Newbie
    Replies: 1
    Last Post: 9th September 2008, 21:16
  5. QThread , GUI freeze
    By cs_raja in forum Qt Programming
    Replies: 4
    Last Post: 19th November 2006, 10:47

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.