Open ishiguroJSK opened 4 years ago
I could see a sample image with rwt_image_view. (e.g. like below)
roslaunch rwt_image_view rwt_image_view.launch rosrun image_view2 publish_lena.py
But after clicking the "view" button for 6 or 7 times, the MjpegCanvas goes wrong.
The terminal message was
$ roslaunch rwt_image_view rwt_image_view.launch ... logging to /home/leus/.ros/log/ca900c0a-c0e6-11ea-8077-7c7a914eb678/roslaunch-W540-8328.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt WARNING: disk usage in log directory [/home/leus/.ros/log] is over 1GB. It's recommended that you use the 'rosclean' command. started roslaunch server http://W540:34877/ SUMMARY ======== CLEAR PARAMETERS * /rosbag_record_server/ * /web_video_server/ PARAMETERS * /rosapi/params_glob: [*] * /rosapi/services_glob: [*] * /rosapi/topics_glob: [*] * /rosbridge_websocket/address: 0.0.0.0 * /rosbridge_websocket/authenticate: False * /rosbridge_websocket/bson_only_mode: False * /rosbridge_websocket/delay_between_messages: 0 * /rosbridge_websocket/fragment_timeout: 600 * /rosbridge_websocket/max_message_size: None * /rosbridge_websocket/params_glob: [*] * /rosbridge_websocket/port: 8888 * /rosbridge_websocket/retry_startup_delay: 5 * /rosbridge_websocket/services_glob: [*] * /rosbridge_websocket/topics_glob: [*] * /rosbridge_websocket/unregister_timeout: 10 * /rosbridge_websocket/use_compression: False * /rosbridge_websocket/websocket_external_port: None * /rosbridge_websocket/websocket_ping_interval: 0 * /rosbridge_websocket/websocket_ping_timeout: 30 * /rosdistro: melodic * /rosversion: 1.14.6 * /web_video_server/address: 127.0.0.1 * /web_video_server/port: 8080 NODES / rosapi (rosapi/rosapi_node) rosbag_record_server (rwt_image_view/rosbag_record_server.py) rosbridge_websocket (rosbridge_server/rosbridge_websocket) roswww (roswww/webserver.py) web_video_server (web_video_server/web_video_server) auto-starting new master process[master]: started with pid [8341] ROS_MASTER_URI=http://localhost:11311 setting /run_id to ca900c0a-c0e6-11ea-8077-7c7a914eb678 process[rosout-1]: started with pid [8352] started core service [/rosout] process[roswww-2]: started with pid [8360] process[rosbridge_websocket-3]: started with pid [8361] process[rosapi-4]: started with pid [8362] process[web_video_server-5]: started with pid [8363] process[rosbag_record_server-6]: started with pid [8364] [ INFO] [1594190807.450827333]: Waiting For connections on 127.0.0.1:8080 2020-07-08 15:46:47+0900 [-] Log opened. [INFO] [1594190807.670440]: Rosapi started 2020-07-08 15:46:47,694 - roswww - INFO - roswww : # of packages : 427 2020-07-08 15:46:47,694 - roswww - INFO - roswww : Weg Page root : www 2020-07-08 15:46:47+0900 [-] registered capabilities (classes): 2020-07-08 15:46:47+0900 [-] - rosbridge_library.capabilities.call_service.CallService 2020-07-08 15:46:47+0900 [-] - rosbridge_library.capabilities.advertise.Advertise 2020-07-08 15:46:47+0900 [-] - rosbridge_library.capabilities.publish.Publish 2020-07-08 15:46:47+0900 [-] - rosbridge_library.capabilities.subscribe.Subscribe 2020-07-08 15:46:47+0900 [-] - <class 'rosbridge_library.capabilities.defragmentation.Defragment'> 2020-07-08 15:46:47+0900 [-] - rosbridge_library.capabilities.advertise_service.AdvertiseService 2020-07-08 15:46:47+0900 [-] - rosbridge_library.capabilities.service_response.ServiceResponse 2020-07-08 15:46:47+0900 [-] - rosbridge_library.capabilities.unadvertise_service.UnadvertiseService 2020-07-08 15:46:47,788 - roswww - INFO - roswww : Initialised 2020-07-08 15:46:47,788 - roswww - INFO - roswww : Attempting to start webserver on port 8000 2020-07-08 15:46:47,789 - roswww - INFO - roswww : Webserver successfully started on port 8000 2020-07-08 15:46:47+0900 [-] WebSocketServerFactory starting on 8888 2020-07-08 15:46:47+0900 [-] Starting factory <autobahn.twisted.websocket.WebSocketServerFactory object at 0x7f6f87814910> 2020-07-08 15:46:47+0900 [-] [INFO] [1594190807.864373]: Rosbridge WebSocket server started at ws://0.0.0.0:8888 2020-07-08 15:46:52+0900 [-] [INFO] [1594190812.305308]: Client connected. 1 clients total. [ INFO] [1594190814.049349666]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594190815.941005229]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594190816.978707051]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594190818.319926652]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594190819.767715724]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594190821.257492412]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594190881.315866039]: Handling Request: /stream?topic=/image&width=720&height=540
After the browser refresh, I could see the image and got these message.
2020-07-08 15:48:01+0900 [-] [INFO] [1594190881.316716]: Client disconnected. 0 clients total. 2020-07-08 15:48:01+0900 [-] [INFO] [1594190881.422902]: Client connected. 1 clients total. [ INFO] [1594190881.447814991]: Removed Stream: /image [ INFO] [1594190881.447868542]: Removed Stream: /image [ INFO] [1594190881.447890160]: Removed Stream: /image [ INFO] [1594190881.447912288]: Removed Stream: /image [ INFO] [1594190881.947888841]: Removed Stream: /image [ INFO] [1594190881.947991110]: Removed Stream: /image [ INFO] [1594190881.948032658]: Removed Stream: /image
I think this is a kind of memory leak or unreleased resource behaviour. At the time we click the "view" button, the "mjpeg_canvas" variable seems to be released, https://github.com/tork-a/visualization_rwt/blob/2504cd0f18d5f7c785da76d6e51bbc227944352d/rwt_image_view/www/js/rwt_image_view_main.js#L51-L55 but the MJPEGCANVAS.Viewer class has "setInterval" function, https://github.com/rctoris/mjpegcanvasjs/blob/6e903db97006976fff4d4efed344962250362b82/build/mjpegcanvas.js#L310 and this disturb the GC (cf. https://www.ibm.com/developerworks/jp/web/library/wa-jsmemory/index.html)
I tried adding the "clearInterval()" method to the web_video_server, and it seems to be working.
diff --git a/build/mjpegcanvas.js b/build/mjpegcanvas.js index eaa3e58..2f01fc4 100644 --- a/build/mjpegcanvas.js +++ b/build/mjpegcanvas.js @@ -307,7 +307,7 @@ MJPEGCANVAS.Viewer = function(options) { this.changeStream(topic); // call draw with the given interval or rate - setInterval(draw, drawInterval); + this.timer = setInterval(draw, drawInterval); }; MJPEGCANVAS.Viewer.prototype.__proto__ = EventEmitter2.prototype;
diff --git a/rwt_image_view/www/js/rwt_image_view_main.js b/rwt_image_view/www/js/rwt_image_view_main.js index 86c12a5..59e5721 100644 --- a/rwt_image_view/www/js/rwt_image_view_main.js +++ b/rwt_image_view/www/js/rwt_image_view_main.js @@ -50,6 +57,8 @@ $(function() { $("#topic-form").submit(function(e) { if (mjpeg_canvas) { // remove the canvas here + clearInterval(mjpeg_canvas.timer); mjpeg_canvas = null; $("#canvas-area canvas").remove(); }
[ INFO] [1594209262.803311978]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209264.383940033]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209265.834407068]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209267.003788983]: Removed Stream: /image [ INFO] [1594209267.107997476]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209267.503785017]: Removed Stream: /image [ INFO] [1594209267.503890072]: Removed Stream: /image [ INFO] [1594209268.520604637]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209269.904724740]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209271.019983899]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209272.394187323]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209272.509961334]: Removed Stream: /image [ INFO] [1594209272.510025172]: Removed Stream: /image [ INFO] [1594209273.008559493]: Removed Stream: /image [ INFO] [1594209273.522705938]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209274.777009174]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209275.925728269]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209276.968478897]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209280.817284694]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209281.009938965]: Removed Stream: /image [ INFO] [1594209281.009982548]: Removed Stream: /image [ INFO] [1594209281.009996681]: Removed Stream: /image [ INFO] [1594209281.010007002]: Removed Stream: /image [ INFO] [1594209281.503753135]: Removed Stream: /image [ INFO] [1594209281.503824608]: Removed Stream: /image [ INFO] [1594209281.624059960]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209283.341362886]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209284.719536145]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209286.654600997]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209288.419764268]: Handling Request: /stream?topic=/image&width=720&height=540 [ INFO] [1594209288.519577063]: Removed Stream: /image [ INFO] [1594209288.519616307]: Removed Stream: /image [ INFO] [1594209288.519629126]: Removed Stream: /image [ INFO] [1594209288.519655112]: Removed Stream: /image [ INFO] [1594209289.003761334]: Removed Stream: /image
If anyone report same behaviour, it helps me.
thanks, please send pr
I could see a sample image with rwt_image_view. (e.g. like below)
But after clicking the "view" button for 6 or 7 times, the MjpegCanvas goes wrong.
The terminal message was
After the browser refresh, I could see the image and got these message.
I think this is a kind of memory leak or unreleased resource behaviour. At the time we click the "view" button, the "mjpeg_canvas" variable seems to be released, https://github.com/tork-a/visualization_rwt/blob/2504cd0f18d5f7c785da76d6e51bbc227944352d/rwt_image_view/www/js/rwt_image_view_main.js#L51-L55 but the MJPEGCANVAS.Viewer class has "setInterval" function, https://github.com/rctoris/mjpegcanvasjs/blob/6e903db97006976fff4d4efed344962250362b82/build/mjpegcanvas.js#L310 and this disturb the GC (cf. https://www.ibm.com/developerworks/jp/web/library/wa-jsmemory/index.html)
I tried adding the "clearInterval()" method to the web_video_server, and it seems to be working.
If anyone report same behaviour, it helps me.