2

I have a QT based application that has been running for several years using Windows. It opens 3 different UDP sockets, connects the readyRead signal to a slot, and parses the data from all three. I have had no troubles with this part of the application at all.

I recently ported it to OS X, using QT 5.4. It appears to run fine until I minimize the application using the little orange button on the title bar. When I restore it, only one of the sockets continues to receive data. I have verified that the data is still being sent to the socket--it's just not triggering readyRead.

If I restart, all is fine.

The one difference between the working socket and the others is that the working one is connected to a device that must be prompted, so at 1 Hz I write to the socket. The other sockets have should spit data without being prompted.

I did try sending data to them anyway, just to make sure the socket wasnt hanging up at the OS level somehow, but it made no difference. Nothing has made a difference in fact. Each socket is opened the same way--I create the socket, bind it to a port number, and connect it to a slot.

altitudeSocket = new   QUdpSocket(this);
altitudeSocket->bind(altitudeInSocketNumber);
connect (altitudeSocket,SIGNAL(readyRead()),this,SLOT(sledSocketDataPending()));

switchSocket = new   QUdpSocket(this);
switchSocket->bind(switchInSocketNumber);
connect (switchSocket, SIGNAL(readyRead()),this,SLOT(sledSocketDataPending()));

depthSocket = new   QUdpSocket(this);
depthSocket->bind(depthInSocketNumber);
connect (depthSocket, SIGNAL(readyRead()),this,SLOT(sledSocketDataPending()));

Is there something special I need to do in OS X programming to handle window minimization?

jhowland
  • 365
  • 1
  • 5
  • 19
  • It's possibly a Qt bug, but you'd need to make a stand-alone test case. Preferably make it single-executable, single source file, and have it launch itself: see [example 1](http://stackoverflow.com/a/18602568/1329652) or [example 2](http://stackoverflow.com/a/31013428/1329652). You'll need the test case anyway to turn this into a valid question. There's no way to answer your question without seeing such a test case. You can be sending the data to yourself, of course. – Kuba hasn't forgotten Monica Jun 30 '15 at 21:59
  • Another suggestion: can you move the `QObject` owning the sockets, and having the slots, to another thread? That way even if OS X somehow blocks the GUI thread, it'll still work. Although I don't think it's the source of the problem. It may be an OS X bug for all I know. You'd probably need two test cases, otherwise acting identically: one using plain C++, native GUI and C socket API, another doing the same thing but ported to Qt. – Kuba hasn't forgotten Monica Jun 30 '15 at 22:01
  • 2
    You might try disabling App Nap to see if that's the cause. You can read up on how to do that here: http://www.tekrevue.com/tip/disable-app-nap-os-x-mavericks/ – MrEricSir Jun 30 '15 at 22:03
  • I have been unable to get back to the problem until today. I disabled AppNap and saw no change in behavior. I tried some other simple things--separating slots, for example and saw no change. I tried sending all the UDP traffic to a single socket (the one that had previously worked), and found that when I did that, and I minimized the application, that socket stopped as well. That seems to indicate some relationship with the incoming data. I don't see any relationship, but thats the symptom. I'm going to try multithreading next – jhowland Jul 07 '15 at 00:45
  • Hi, Did you get anywhere with this? I have a similar issue where my qt socket (tried both udp and tcp) just stop sending my data once I have switched to another app and then back to the app and ask it to write some more data (button press). This only happens on osx and I have tried on 2 macbooks running el caption. Been at this for 3 days. Runs fine on Windows. – user1379811 Jul 28 '16 at 11:53
  • Have you confirmed in activity monitor that your application truly isn't in app nap? – Kuba hasn't forgotten Monica Jul 28 '16 at 21:04
  • I can confirm app nap isn't on for my app when this problem occurs – user1379811 Jul 29 '16 at 00:26
  • I re-implemented my application and put the UDP socket in a separate thread and was able to get what I needed. – jhowland Jul 29 '16 at 20:53

0 Answers0