Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. qt 6.3 & asyncify
Forum Updated to NodeBB v4.3 + New Features

qt 6.3 & asyncify

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
6 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • sitesvS Offline
    sitesvS Offline
    sitesv
    wrote on last edited by sitesv
    #1

    Hi!

    1. Is It correct to activate asyncify by adding key and value "-device-option QT_EMSCRIPTEN_ASYNCIFY=1" while configuring qt before using cmake?

    2. How to check is asyncify enabled?

    This code (in case of using QEventLoop) still doesn't work.

    bool myclass::func(){
          ....
         QEventLoop el;
         connect(this, &myclass::mysignal, &el, &QEventLoop::exit));
        el.exec();
    
        /// unreachable string
    }
    
    void myclass::recieve_msg(const QByteArray &message){ // QWebSocket callback func
         ...
         emit mysignal(0);
    }
    
    1 Reply Last reply
    0
    • sitesvS Offline
      sitesvS Offline
      sitesv
      wrote on last edited by
      #2

      QEventLoop::exec() blocks all events and doesn't allows callback QWebSocket incoming stream...
      (qt 6.3 was configured with -device-option QT_EMSCRIPTEN_ASYNCIFY=1)

      1 Reply Last reply
      0
      • sitesvS Offline
        sitesvS Offline
        sitesv
        wrote on last edited by
        #3

        @lorn-potter Could you please comment my problem?

        W 1 Reply Last reply
        0
        • sitesvS sitesv

          @lorn-potter Could you please comment my problem?

          W Offline
          W Offline
          wenqing zhong
          wrote on last edited by
          #4

          @sitesv I known what you concern, so I think my experience may help you.
          When we make network program, the communication protocol sometimes is complicate, we need send request and wait reponse, and depend on the reply and request more different datas, blabla,... and then can process the display. So the qt websocket provide the signal/slot is inadequate. Most of the time, we need wait the network response, and do next step.
          My program work fine in windows/linux, but when compile in wasm. I meet the same problem as you.
          My code like below:

           m_websocket.sendTextMessage(request_str);
            bool timeout=true, dataRet=false;
            QElapsedTimer netTimer;
            netTimer.start();
            while(netTimer.elapsed() < 3000) //3 seconds timeout
              {
                  //in websocket receive message slot, process and set dataRet true
                  if (dataRet)
                  {
                    timeout=false;
                    break;
                  }
                  QCoreApplication::processEvents(QEventLoop::AllEvents,100);
              }
            qDebug() << "processEvents ok";
          

          The above code doesn't work in qt6.2.4 even if I compile the wasm with asyncify.
          The key problem is the processEvents(QEventLoop) doesn't work in wasm. I try other way, include thread... but all don't work.
          After I success compile qt6.3.0 with asyncify. I found it works!!!
          So I think you can use this way, don't need to solve that QEventLoop problem.
          QT wasm is really new, it's a exciting tech. but have many constrain. Now I need process the popup menu problem....

          sitesvS 1 Reply Last reply
          0
          • W wenqing zhong

            @sitesv I known what you concern, so I think my experience may help you.
            When we make network program, the communication protocol sometimes is complicate, we need send request and wait reponse, and depend on the reply and request more different datas, blabla,... and then can process the display. So the qt websocket provide the signal/slot is inadequate. Most of the time, we need wait the network response, and do next step.
            My program work fine in windows/linux, but when compile in wasm. I meet the same problem as you.
            My code like below:

             m_websocket.sendTextMessage(request_str);
              bool timeout=true, dataRet=false;
              QElapsedTimer netTimer;
              netTimer.start();
              while(netTimer.elapsed() < 3000) //3 seconds timeout
                {
                    //in websocket receive message slot, process and set dataRet true
                    if (dataRet)
                    {
                      timeout=false;
                      break;
                    }
                    QCoreApplication::processEvents(QEventLoop::AllEvents,100);
                }
              qDebug() << "processEvents ok";
            

            The above code doesn't work in qt6.2.4 even if I compile the wasm with asyncify.
            The key problem is the processEvents(QEventLoop) doesn't work in wasm. I try other way, include thread... but all don't work.
            After I success compile qt6.3.0 with asyncify. I found it works!!!
            So I think you can use this way, don't need to solve that QEventLoop problem.
            QT wasm is really new, it's a exciting tech. but have many constrain. Now I need process the popup menu problem....

            sitesvS Offline
            sitesvS Offline
            sitesv
            wrote on last edited by
            #5

            @wenqing-zhong Thank you for advice.
            BTW, I don't understand for which purpose wasm exists, If we always can start standart app in vnc mode...

            W 1 Reply Last reply
            0
            • sitesvS sitesv

              @wenqing-zhong Thank you for advice.
              BTW, I don't understand for which purpose wasm exists, If we always can start standart app in vnc mode...

              W Offline
              W Offline
              wenqing zhong
              wrote on last edited by
              #6

              @sitesv em, that's depends. To me, wasm is wonderful, because my clients always require B/S solution. with wasm I can support one code for both C/S and B/S, and I don't need java guys :)

              1 Reply Last reply
              0
              • JonBJ JonB referenced this topic on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved