# Performance drop in slicer while receiving openigtlink messages as server

**URL:** <https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098>\
**Category:** Support\
**Tags:** openigtlink\
**Created:** [June 6, 2018, 7:06pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098 "2018-06-06T19:06:35Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![roozbehshams](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/roozbehshams/32/1544_2.png) [@roozbehshams](https://discourse.slicer.org/u/roozbehshams)\
**Post date:** [June 6, 2018, 7:06pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/1 "2018-06-06T19:06:35Z")

</div>

Operating system: Windows 10  
Slicer version: 4.8.1  
Expected behavior: No significant performance drop (at least in 3D view) while receiving messages.  
Actual behavior: significant performance drop

When using openigtlink module in slicer in server mode, if the received message rate exceeds 10 message/second there’s visible frame rate drop in the 3D view drops. I’ve been using a matlab script to connect to the server and send messages. (not sure if this extends to whole slicer performance or only the 3D view; I assume it’s the former). To reproduce this:

1. Create an IGTLink server node in slicer and set check for CRC off with:

```auto
getNode("IGTLCon*").SetCheckCRC(0)

```

1. You can use this script to rotate the 3D scene. The jitters can be seen while rotating with the mouse as well.

```auto
layoutManager = slicer.app.layoutManager()
layoutManager.setLayout(4) # 3D only

threeDWidget = layoutManager.threeDWidget(0)
threeDView = threeDWidget.threeDView()
threeDView.resetFocalPoint()

threeDController = threeDWidget.threeDController()
threeDController.spinView(True)
threeDView.setAnimationIntervalMs(5)
threeDView.setSpinIncrement(1)

```

1. Run the performance\_drop\_test\_slicer.m script in this [repo](https://github.com/roozbehshams/MatlabOpenIGTLink/tree/NativeMatlabTCPIP/src) or any other openigtlink client to send messages to the slicer server.

There’s an FPS drop in the 3D viewer while the messages are being sent. As you can see here:

![slicer-performance-drop](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/7/d7e60ec4de1d0c5d505d3704696695f98d02163e.gif)

On a side note, the SetCheckCRC function doesn’t work in the current nightly build (4.9.0-2018-06-05), is there a substitute for it?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 6, 2018, 11:50pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/2 "2018-06-06T23:50:37Z")

</div>

A related issue has been recently fixed. Could you please try the latest nightly version?

---

<div class="post-metadata">

**Author:** ![roozbehshams](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/roozbehshams/32/1544_2.png) [@roozbehshams](https://discourse.slicer.org/u/roozbehshams)\
**Post date:** [June 8, 2018, 11:08pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/3 "2018-06-08T23:08:20Z")

</div>

A problem that I have with running this with the nightly is that I can’t turn off the CRC check of the IGTLink node. SetCheckCRC(0) doesn’t work in the nightly version. ( I get an error saying the node doesn’t have a SetCRCCheck attribute).  
The node type seems to be different in nightly (vtkSlicerOpenIGTLinkIFModuleMRMLPython.vtkMRMLIGTLConnectorNode) vs stable (vtkCommonCorePython.vtkMRMLIGTLConnectorNode)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 9, 2018, 1:11pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/4 "2018-06-09T13:11:39Z")

</div>

I’ve checked the code and indeed, as a result of some recent refactoring, CRC check is not exposed in the MRML node interface. I’ve submitted a pull request that adds back this feature: [https://github.com/openigtlink/SlicerOpenIGTLink/pull/37](https://github.com/openigtlink/SlicerOpenIGTLink/pull/37). It’ll be probably integrated within a few days.

---

<div class="post-metadata">

**Author:** ![leochan2009](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leochan2009/32/519_2.png) [@leochan2009](https://discourse.slicer.org/u/leochan2009)\
**Post date:** [June 11, 2018, 5:42pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/5 "2018-06-11T17:42:22Z")

</div>

@roozbehshams  
Thanks for your report  
pull request merged, you could check the nightly build tomorrow

---

<div class="post-metadata">

**Author:** ![roozbehshams](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/roozbehshams/32/1544_2.png) [@roozbehshams](https://discourse.slicer.org/u/roozbehshams)\
**Post date:** [June 13, 2018, 6:48pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/6 "2018-06-13T18:48:55Z")

</div>

Thanks @lassoan @leochan2009 . I tested the nightly, SetCheckCRC is exposed now but slicer crashes when it receives a message. There’s no error message, it’s just closed. I assume it can be reproduced with any openIGTLInk, but you can use the matlab script in my original post. It can be found here: [github.com/roozbehshams/MatlabOpenIGTLink/tree/NativeMatlabTCPIP/src](http://github.com/roozbehshams/MatlabOpenIGTLink/tree/NativeMatlabTCPIP/src) , the performance\_drop\_test\_slicer script.

---

<div class="post-metadata">

**Author:** ![leochan2009](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leochan2009/32/519_2.png) [@leochan2009](https://discourse.slicer.org/u/leochan2009)\
**Post date:** [June 13, 2018, 7:41pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/7 "2018-06-13T19:41:44Z")

</div>

Thanks for reporting, i will debug immediately

---

<div class="post-metadata">

**Author:** ![leochan2009](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leochan2009/32/519_2.png) [@leochan2009](https://discourse.slicer.org/u/leochan2009)\
**Post date:** [June 13, 2018, 8:35pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/8 "2018-06-13T20:35:34Z")

</div>

Hi,  
I tested the OpenIGTLinkIF module using the [TrackerServer program](https://github.com/openigtlink/OpenIGTLink/blob/master/Examples/Tracker/TrackerServer.cxx) in OpenIGTLink library.  
The receiving message is working well and Set/GetCheceCRC functions are working as well.  
Unfortunately i don’t have Matlab, so i could not check your code.  
Probably Andras could check this issue at the same time @lassoan

Best,  
Longquan

---

<div class="post-metadata">

**Author:** ![roozbehshams](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/roozbehshams/32/1544_2.png) [@roozbehshams](https://discourse.slicer.org/u/roozbehshams)\
**Post date:** [June 13, 2018, 8:39pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/9 "2018-06-13T20:39:40Z")

</div>

Thanks for looking into it. The problem happens when slicer is used in server mode. I think you should be able to reproduce it if you use the TrackerClient.

---

<div class="post-metadata">

**Author:** ![leochan2009](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/leochan2009/32/519_2.png) [@leochan2009](https://discourse.slicer.org/u/leochan2009)\
**Post date:** [June 13, 2018, 10:38pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/10 "2018-06-13T22:38:57Z")

</div>

Hi,

I just checked with TrackerClient, slicer doesn’t crash either.  
When you use the trackerClient for testing, just add one line to set the device name.  
transMsg-\> SetDeviceName(“Tracker”);

> <https://github.com/openigtlink/OpenIGTLink/blob/master/Examples/Tracker/TrackerClient.cxx#L77>

  
otherwise, in slicer you will received bunch of transformation nodes.

Best,  
Longquan

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 14, 2018, 2:22am UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/11 "2018-06-14T02:22:51Z")

</div>

I’ve managed to reproduce the crash, it was due to incorrect receiving of STRING message in OpenIGTLinkIF. I’ve pushed a fix ([https://github.com/openigtlink/SlicerOpenIGTLink/pull/38](https://github.com/openigtlink/SlicerOpenIGTLink/pull/38)).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 14, 2018, 2:53am UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/12 "2018-06-14T02:53:49Z")

</div>

I could not reproduce the performance drop with latest nightly version of Slicer. Update rate of 3D view on my computer is about 150FPS - with and without continuously streaming messages from Matlab using your script (I’ve changed `for t=0:0` to `for t=0:1000` to send many messages).

---

<div class="post-metadata">

**Author:** ![roozbehshams](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/roozbehshams/32/1544_2.png) [@roozbehshams](https://discourse.slicer.org/u/roozbehshams)\
**Post date:** [June 14, 2018, 2:06pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/13 "2018-06-14T14:06:40Z")

</div>

Thanks Longquan, Andras!  
Out of curiosity, how can I check the fps of the 3D view ?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 14, 2018, 9:10pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/14 "2018-06-14T21:10:07Z")

</div>

> [@roozbehshams](#):
>
> how can I check the fps of the 3D view ?

Click push-pin icon in the top-left corner of the 3D view, click the `...` button, click `Show/hide frames per second (FPS)`.

---

<div class="post-metadata">

**Author:** ![roozbehshams](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/roozbehshams/32/1544_2.png) [@roozbehshams](https://discourse.slicer.org/u/roozbehshams)\
**Post date:** [June 18, 2018, 2:17pm UTC](https://discourse.slicer.org/t/performance-drop-in-slicer-while-receiving-openigtlink-messages-as-server/3098/15 "2018-06-18T14:17:41Z")

</div>

Thanks! I also checked with the latest nightly and the performance is as expected.
