Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
5.15.1
Description
We have created a scriptable state machine using the QJSEngine but are now running into an issue. We use a script which is called every 500 miliseconds to poll during idle in order to trigger a transition if required.
If we keep the system running in idle for a while we keep getting an issue on the call to one of our registered C++ methods.
The issue is as follows: We have a method registered to the QJSEngine which has two parameters. The first is a const QString& "key" and the second being a QJSValue "value". Sometimes when we call this method the "value" parameter will be undefined.
This behaviour seems to be happening at quite random intervals, sometimes after about 5 minutes of running the system, sometimes 20, sometimes 2 hours. I have not been able to figure out what the reason for these random intervals is.
In my debugging efforts I have changed the call so it's just a string literal coming in from the JS side, doing this still made the bug reproduce. I have also changed the "value" parameter's type to a const QJSValue& and this has only had the effect of changing it from a QJSValue "undefined" to a QJSValue::Int 0.
I need help figuring out what the cause of this issue is as this call is one of the core elements of our system and we can't miss any of these values.
Below are snippets from the JS and C++ code:
//JS export function CheckWaitFlag() { // Set the wait flag to false (stop waiting and continue) if MSM has no pending intent states besides the optional current 'stateName' value. var size = MSM.GetIntentStackSizeJS(); var wait = size === 0; if (size === 1) { var intentStatename = MSM.GetIntentStateNameJS(); wait = !(intentStatename === stateName); } var flagValue = String(wait ? "true" : "false"); MSM.SetStoreJS("wait_flag", flagValue); } //C++ int ManagedStateMachine::SetStoreJS(const QString &key, const QJSValue& value) { //temp variable introduced to help debug rare bug FBLT-7129 auto temp = value.toVariant(); QJsonValue asValue = QJsonValue::fromVariant(temp); return (int)SetStore(key, asValue); }