Ros.js cannot handle very large messages
Migrated from https://github.com/RobotWebTools/rosjs/issues/27
@baalexander :
Very large messages, like some point cloud streams, cause the browser to freeze. This was originally reported by @jihoonl, who emailed me example code to reproduce (I uploaded it here, but haven't checked it out yet).
If the issue is blocking the main thread, one thing could be using webworkers to process the messages. Still need to investigate.
Web Worker
Migrated from https://github.com/RobotWebTools/roslibjs/issues/34
@rctoris :
@jihoonl :
Web worker allows to have use background thread in the browser.
It may help to keep the interface responsive while it receives the high volume of data from socket.
@rctoris :
Could address things like https://github.com/RobotWebTools/map2djs/issues/5
The link to original example https://github.com/downloads/RobotWebTools/rosjs/example.tar.gz. It doesn't have a data bag with :( I'll have to generate a large point cloud to reproduce.
Thought I'd add further insight on this issue. It appears that the ROS.Topic.subscribe code does not implement queue_size on the client side, so data piles up if the listener function can't process data as quickly as it comes it. I implemented a workaround to provide a queue size of 1 by using a separate display "thread" to process the data, leaving the listener.subscribe function to just copy the latest message to a globally shared variable and exit. The display thread is set up using the setInterval() call.
I don't know if I should report the queue_size problem as a separate issue or not, but the fact that queue_size is a parameter to ROSLIB.Topic but not used makes it seem like a good candidate.
related: https://github.com/RobotWebTools/rosbridge_suite/pull/190