Details
Description
QOpcUaClient consumes too much CPU when subscription is created even if no data is changing.
Looking into code, I have found following lines in qopen62541backend.cpp:1013
void Open62541AsyncBackend::sendPublishRequest() { if (!m_uaclient) return; if (!m_sendPublishRequests) { return; } // If BADSERVERNOTCONNECTED is returned, the subscriptions are gone and local information can be deleted. if (UA_Client_run_iterate(m_uaclient, 1) == UA_STATUSCODE_BADSERVERNOTCONNECTED) { qCWarning(QT_OPCUA_PLUGINS_OPEN62541) << "Unable to send publish request"; m_sendPublishRequests = false; cleanupSubscriptions(); return; } m_subscriptionTimer.start(0); }
my understanding is that calling UA_Client_run_iterate with timeout 1 msec and start timer with interval 0 msec afterwards causes that this function is called almost like busy-loop and cause 12% CPU load on my box.
Note
QObject::connect(&m_subscriptionTimer, &QTimer::timeout,
this, &Open62541AsyncBackend::sendPublishRequest);
in Open62541AsyncBackend::Open62541AsyncBackend