MacOS: Qt 5.7.0 constantly reading SystemConfiguration



  • Hi,

    Here's an interesting one: I've got a substantial amount of code in this program, so I won't bother posting code yet. It uses a few network/system configuration functions to get the system configuration, has a tiny webserver inside and also does http requests.

    I recently upgraded from Qt 5.3 to 5.7 and found something weird. The app is polling the SystemConfiguration every 10 seconds.

    2017 Mar 4 22:34:16 501 10912 TestApp     32 0 /Library/Preferences/SystemConfiguration/preferences.plist
    2017 Mar 4 22:34:16 501 10912 TestApp 32 0 /System/Library/Frameworks/SystemConfiguration.framework/Resources/English.lproj/NetworkInterface.strings
    2017 Mar 4 22:34:16 501 10912 TestApp 32 0 /System/Library/Frameworks/SystemConfiguration.framework/Resources/English.lproj/NetworkInterface.strings
    2017 Mar 4 22:34:16 501 10912 TestApp 32 0 /System/Library/Frameworks/SystemConfiguration.framework/Resources/English.lproj/NetworkInterface.strings
    2017 Mar 4 22:34:16 501 10912 TestApp 32 0 /System/Library/Frameworks/SystemConfiguration.framework/Resources/English.lproj/NetworkInterface.strings
    2017 Mar 4 22:34:16 501 10912 TestApp 32 0 /System/Library/Frameworks/SystemConfiguration.framework/Resources/English.lproj/NetworkInterface.strings
    

    And on and on. I've profiled all the functions inside the app (logging when something is called) and got nothing that was on the same timing as these requests. There's no 10 second timer at all.

    Has anyone come across this behaviour and how can I stop this?

    Thanks!


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you double check with a more recent version of Qt ? The current is 5.8.



  • Hi,

    Luckily I had a test VM where Qt 5.8.0 was on. I copiled the app on there and looked at the open files, same thing.


  • Moderators

    @smitmartijn I don't know if you can use something like strace on osx I haven't tried it, but if you can run it to see what your app is doing when it is using SystemConfiguration.

    That is definitely weird unless maybe you are having some network connection attempt from your app or something that is using SystemConfiguration for the network properties.

    If you could try to make a simple test app that duplicates this behavior for us to see the code/test with it would be easier to help diagnose.

    I've done a lot of OSX coding and haven't seen that with Qt, however, I haven't done much since Qt 5.5 or so on osx. So it could be a bug, but more than likely it's something your app is doing. Especially check any place that access a network resource for a potential issue.



  • For those interested, this turned out to be an issue with QNetworkAccessManager in Qt 5.3.1 and above (still not fixed!) where the network interfaces are rescanned every 10 seconds when you're on a wireless connection.

    More information:

    https://bugreports.qt.io/browse/QTBUG-46015
    https://bugreports.qt.io/browse/QTBUG-40332

    It's pretty unbelievable that this hasn't been fixed yet, considering it's pretty disruptive. To implement a workaround, add an environment variable:

    qputenv("QT_BEARER_POLL_TIMEOUT", QByteArray::number(-1));


  • Moderators

    @smitmartijn Wow, thanks for following up. That is crazy that hasn't been fixed yet. A 10 second polling seems like just plain bad design. Especially if it's causing logging every time.

    The beauty of Qt is you can always fix it yourself. :) I've done that a few times. They will probably even take a patch from you to fix it if it doesn't cause other issues or is against their coding standards, etc.



  • @ambershark No problem. I'm not going to pretend I have the skills to fix it in the Qt source though. ;-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.