Open nunoguedelha opened 2 years ago
At some point we suspected that the line scattering observed in the fake-framegrabber rendering was due to the simultaneous display of multiple frames, and thus related to the Historical requests (refer to this documentation section). This seems now to be a wrong lead, as we can see in the screenshot below that even a single frame includes multiple lines instead of a singe one for the fake framegrabber.
Originally posted by @nunoguedelha in https://github.com/ami-iit/yarp-openmct/issues/71#issuecomment-1063569388
Logging the received image data on a yarp port
We publish the image data received through the plugin
RealtimeTelemetryPlugin
on a Yarp port/yarpjs/cameraEcho:o
of typebottle
.For this we added the support of
socket.io
andyarp.js
features in the visualizer plugin installation page:We then use the stream video plugin example of
yarp.js
repository to display the streamed images. We can see in the stream the same scattered lines instead of a single one, as we see in the Open-MCT based visualizer.We can conclude that the line scattered lines issue occurs in the data transmission between the telemetry server and the Open-MCT based visualizer client.
Sending a fixed frame
If we break the telemetry server we get a constant sample and thus a fixed frame on the visualizer, similar to the output illustrated on https://github.com/ami-iit/yarp-openmct/issues/71#issuecomment-1063569388, i.e with scattered lines.
This confirms the observation from the previous experiment. We then implement some changes in order to have the server send the raw image data buffer, and the client to apply the conversion to the URI format and base 64 (
yarp.getImageSrc(...)
): https://github.com/ami-iit/yarp-openmct/blob/34cae51cd90077c7d7d63f01f937562d5839ae15/openmctStaticServer/realtime-telemetry-plugin.js#L10-L21This way it's easier to compare the data sent and received.
I'm suspecting an issue with the way the data transmission is scheduled, which could cause a race condition leading to concurrent data access in the case of big chunks of data, typically image data.
Originally posted by @nunoguedelha in https://github.com/ami-iit/yarp-openmct/issues/71#issuecomment-1068398512
This way it's easier to compare the data sent and received.
- We log the data received on port
/yarpjs/camLeftEye:i
into a yarpview port- After running the telemetry server and client visualizer, we disconnect the framegrabber ouput:
yarp disconnect /icubSim/camLeftEye /yarpjs/camLeftEye:i
This way, we get a fixed frame on the visualizer, and also on the yarpview display as well:
We can see that the outputs are well aligned. We then break the telemetry server and the client visualizer in order to get in the debugger the sent and received buffers.
point.value.buffer
in the subscribers notification sendernotifySubscribers
. https://github.com/ami-iit/yarp-openmct/blob/3d6105dc8efc7de4eefeef9ed27feba60bc21eba/openmctStaticServer/realtime-telemetry-plugin.js#L5-L11data.value.buffer
in theRealtimeTelemetryPlugin
plugin. https://github.com/ami-iit/yarp-openmct/blob/34cae51cd90077c7d7d63f01f937562d5839ae15/iCubTelemVizServer/realtime-server.js#L20-L24The buffers are identical.
The problem is not in the transmission of the data between the server and client, but rather in the implementation of the yarp image type port reading.
From the
yarp.js
repository examples, we know that the implementation of image type port reading through websockets works pretty well. For that reason we'll try reading the port directly via yarp socket in the visualizer client (no history shall be supported).
Originally posted by @nunoguedelha in https://github.com/ami-iit/yarp-openmct/issues/71#issuecomment-1068702205
A debug version of the fix is implemented in https://github.com/ami-iit/yarp-openmct/tree/e5e0f28fbe8708954ac8240bfc43819b2955ff02.
This change broke the shutdown sequence. Fixing...
The proper closure of the
iCubTelemVizServer
server was blocked by theopenmctStaticServer
server hanging at closure itself.Received SIGINT ... { status: 'WRPLY', message: 'Process (PID 36504) OpenMCT Server stopping (signal SIGINT) ...' } iCub Telemetry Server closing: no further connection requests accepted. Control Console Server closing: no further connection requests accepted. [OPEN-MCT STATIC SERVER] stdout: Received SIGINT ... Open-MCT Visualizer Server closing: no further incoming requests accepted. Refreshing the visualizer web page will fail. Open-MCT Visualizer Server closed: all sockets closed.
The closure process resumes normally after we kill the
nodejs
process running theopenmctStaticServer
server.iCub Telemetry Server closing: no further "subscribe"/"unsubscribe" requests accepted. [INFO] |yarp.os.impl.PortCoreInputUnit| Removing input from /icubSim/inertial to /yarpjs/inertial:i [INFO] |yarp.os.impl.PortCoreInputUnit| Removing input from /icubSim/left_leg/stateExt:o to /yarpjs/left_leg/stateExt:o [INFO] |yarp.os.impl.PortCoreInputUnit| Removing input from /icubSim/camLeftEye to /yarpjs/camLeftEye:i [INFO] |yarp.os.impl.PortCoreInputUnit| Removing input from /walking-coordinator/logger/data:o to /yarpjs/walking-coordinator-logger/data:i iCub Telemetry Server closing: disconnected network ports. Data transmission ended. Closing all Telemetry Server and Control Console sockets! [ 'iCub Telemetry Server closed: all sockets closed.', 'Control Console Server closed: all sockets closed.' ] Waiting for the debugger to disconnect... Process finished with exit code 0
Originally posted by @nunoguedelha in https://github.com/ami-iit/yarp-openmct/issues/71#issuecomment-1069401564
The previous analysis was verified by checking:
then
" block is never executed
https://github.com/ami-iit/yarp-openmct/blob/e5e0f28fbe8708954ac8240bfc43819b2955ff02/iCubTelemVizServer/terminationHandler.js#L23A quick fix ( cd07da9dc6c5c25d9ae70acf80561ad7d6d5d634 ) consists in adding a process.exit()
as a final SIGINT
callback , as done for the iCubTelemVizServer
task
https://github.com/ami-iit/yarp-openmct/blob/e5e0f28fbe8708954ac8240bfc43819b2955ff02/iCubTelemVizServer/terminationHandler.js#L123-L124
We shall later implement a proper fix which does a backup of the original termination callbacks and restores them at the end, as done for the iCubTelemVizServer
task
https://github.com/ami-iit/yarp-openmct/blob/e5e0f28fbe8708954ac8240bfc43819b2955ff02/iCubTelemVizServer/iCubTelemVizServer.js#L197-L203
https://github.com/ami-iit/yarp-openmct/blob/e5e0f28fbe8708954ac8240bfc43819b2955ff02/iCubTelemVizServer/terminationHandler.js#L25-L30
We could actually re-use the class TerminationHandler
as a base, and derived classes for processing the different closures (iCubTelemVizServer
, openmctStaticServer
).
openmctStaticServer
process keeps running most probably for the same reason as iCubTelemVizServer
. We suspect a never expiring timer to be the cause in the node.js internal engine.
function processTimers(now) {
debug('process timer lists %d', now);
nextExpiry = Infinity;
let list;
let ranAtLeastOneList = false;
while (list = timerListQueue.peek()) {
if (list.expiry > now) {
nextExpiry = list.expiry;
return refCount > 0 ? nextExpiry : -nextExpiry;
}
if (ranAtLeastOneList)
runNextTicks();
else
ranAtLeastOneList = true;
listOnTimeout(list, now);
}
return 0;
}
When visualization the fake framegrabber generated image, we see a swiping set of scattered lines instead of a single one.