⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Qt main thread blocked using native thread

  • 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!

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

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

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

Log in to reply