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. PROXY_TO_PTHREAD Support

PROXY_TO_PTHREAD Support

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
3 Posts 2 Posters 757 Views
  • 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.
  • A Offline
    A Offline
    Ahmed Yarub Hani Al Nuaimi
    wrote on 24 Aug 2020, 13:41 last edited by
    #1

    Some of the libraries like OpenSSL and CURL should not run on the main thread, otherwise they will block the application. I could solve this problem on a non-Qt application by using PROXY_TO_PTHREAD for building, which worked without any problem. However, when I add this flag to the Qt based app I start getting errors in this line:

    emscripten::val::global("window").set("onbeforeunload", val::module_property("qtBrowserBeforeUnload"));
    

    In the file qwasmintegration.cpp. It looks like when we proxify the main function emscripten::val::global("window") returns null.
    The solution I had was making CURL requests on another thread. But then, I could not update the models from that thread getting the error:
    Uncaught TypeError: Browser.mainLoop.scheduler is not a function

    So the final solution was updating the model on the main thread using a timer, which is far from being ideal.

    How can I get Qt to work with PROXY_TO_PTHREAD?

    J 1 Reply Last reply 25 Aug 2020, 04:59
    0
    • A Ahmed Yarub Hani Al Nuaimi
      24 Aug 2020, 13:41

      Some of the libraries like OpenSSL and CURL should not run on the main thread, otherwise they will block the application. I could solve this problem on a non-Qt application by using PROXY_TO_PTHREAD for building, which worked without any problem. However, when I add this flag to the Qt based app I start getting errors in this line:

      emscripten::val::global("window").set("onbeforeunload", val::module_property("qtBrowserBeforeUnload"));
      

      In the file qwasmintegration.cpp. It looks like when we proxify the main function emscripten::val::global("window") returns null.
      The solution I had was making CURL requests on another thread. But then, I could not update the models from that thread getting the error:
      Uncaught TypeError: Browser.mainLoop.scheduler is not a function

      So the final solution was updating the model on the main thread using a timer, which is far from being ideal.

      How can I get Qt to work with PROXY_TO_PTHREAD?

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 25 Aug 2020, 04:59 last edited by
      #2

      @Ahmed-Yarub-Hani-Al-Nuaimi said in PROXY_TO_PTHREAD Support:

      But then, I could not update the models from that thread getting the error

      You can emit signal from that thread and update the models in main thread in a slot connected to this signal.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 25 Aug 2020, 14:17
      0
      • J jsulm
        25 Aug 2020, 04:59

        @Ahmed-Yarub-Hani-Al-Nuaimi said in PROXY_TO_PTHREAD Support:

        But then, I could not update the models from that thread getting the error

        You can emit signal from that thread and update the models in main thread in a slot connected to this signal.

        A Offline
        A Offline
        Ahmed Yarub Hani Al Nuaimi
        wrote on 25 Aug 2020, 14:17 last edited by
        #3

        @jsulm thank you for the answer. That might work indeed, but the thing is the same application works on Windows, iOS, Mac, Android, and Linux. I'd have to change the logic just to make it work with Wasm. I could easily run non-Qt application simply by proxifying the call to main, is there a way to get that to work with Qt5 apps?

        1 Reply Last reply
        0

        3/3

        25 Aug 2020, 14:17

        • Login

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