Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt main thread blocked using native thread

Qt main thread blocked using native thread

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 990 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
    AlterX
    wrote on last edited by
    #1

    Hello there,
    I will try to explain what I am experiencing without source code (since it is very long and complex). Let's start...
    My app is right now causing this problem on Android, I am using my cross-platform client lib that is connecting to my server (it has been working for several years without problem) and sending/receiving requests/response in synch/asynch way; this lib is also capable to send file to the server.
    Current situation:
    For the entire lifetime of the app, I have one global instance of the client that is sending and receiving messages without problems; now I need sometimes to send files and when this is needed, I just create a new instance of this object and send the file.
    As soon as I send at least one file to the server, if I try to use the other instance to send message as usual, after server receive the message (and I assume is also replying back) the main thread results stuck and then it is not consuming the signal my class underneath sends (in the app, there is my custom Qt class inheriting from the native cross-platform class). If I continue sending files, this will work without problems, but I can't use the other instance anymore.
    So I isolated the problem and identified the cause in the call of client's native method responsible of sending the files (if I comment out this, the app is not blocking the main thread).
    So what is this native method doing?
    Basically, executed by the main Qt thread, is creating a new native thread that will manage the entire deal with the server, and then it is continuing the normal execution till going back waiting for other events to process!
    So I don't really understand why the global instance is working and then if I send a file using a new instance, the global object is causing the block of main thread.

    Do you have any suggestion to try to understand?

    P.S. I am in process to create another app using the above logic and even if the code is slightly the same, here the main thread is not blocking!

    Qt Ambassador
    Real-time cooperative teams: http://www.softairrealfight.net
    Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

    https://codereview.qt-project.org/...

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! It would be helpful if you could show us some relevant portions of your source code.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlterX
        wrote on last edited by
        #3

        Hi thank you for the response....I thought no one would have replied back :)
        This is the problem...I don't see any relevant part of the code...I can share the creation of native thread, but that is just a pthread create method...rest of the code is normal Qt code.

        Qt Ambassador
        Real-time cooperative teams: http://www.softairrealfight.net
        Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

        https://codereview.qt-project.org/...

        1 Reply Last reply
        0
        • A Offline
          A Offline
          AlterX
          wrote on last edited by
          #4

          Also looking at stack in debug mode and comparing it BEFORE I send a file, and AFTER I sent it, it seems the same to call exactly the same function and going then in epoll_wait.

          Qt Ambassador
          Real-time cooperative teams: http://www.softairrealfight.net
          Free Real-time network platform sdk: https://github.com/AlterX76/Solomon

          https://codereview.qt-project.org/...

          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