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
QtWS25 Last Chance

PROXY_TO_PTHREAD Support

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
3 Posts 2 Posters 750 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.
  • Ahmed Yarub Hani Al NuaimiA Offline
    Ahmed Yarub Hani Al NuaimiA Offline
    Ahmed Yarub Hani Al Nuaimi
    wrote on 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?

    jsulmJ 1 Reply Last reply
    0
    • Ahmed Yarub Hani Al NuaimiA Ahmed Yarub Hani Al Nuaimi

      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?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on 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

      Ahmed Yarub Hani Al NuaimiA 1 Reply Last reply
      0
      • jsulmJ jsulm

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

        Ahmed Yarub Hani Al NuaimiA Offline
        Ahmed Yarub Hani Al NuaimiA Offline
        Ahmed Yarub Hani Al Nuaimi
        wrote on 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

        • Login

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