Tag mismatch in render function leads to pvserver shutdown
Lately I came across a difficult to track and critical bug, which is hidden in the Render function and can lead to a sudden fatal error of Paraview. Inside of the Render function the call to ResetCameraClippingRange calculates the new thickness and informs its observers on change. (https://github.com/Kitware/ParaView/blob/v5.7.0/ParaViewCore/ClientServerCore/Rendering/vtkPVRenderView.cxx#L1415), This was added as a fix for issue #13534 (closed) with the following comment:
BUG #13534 (closed). Reset the clip planes on every render. Since this does not involve any communication, doing this on every render is not a big deal.
Sad thing, in the current ParaView it can_involve_communication which leads to a sudden and fatal error: "Tag mismatch: got 1, expecting 10" on the pvserver side, which causes the server to shut down."
The call of this->ResetCameraClippingRange() is not any more without communication as expected: It can lead to a call of vtkSMRenderViewProxy::SynchronizeCameraProperties, that sends an "InvalidateCachedSelection" stream to the server (tag = 1). But the server is already processing the stream "InteractiveRender", in which it expects to recieve a broadcast (tag=10) (SlaveStartRender(): https://github.com/Kitware/VTK/blob/v8.2.0/Rendering/Parallel/vtkSynchronizedRenderers.cxx#L212) as it's next communication.
Possible Fix: Removing the call to ResetCameraClippingRange fixes this bug, but exposes BUG #13534 (closed) again. Updating the CameraClippingRange before the stream "InteractiveRender" is executed, prevents this tag missmatch and BUG #13534 (closed). Therefore move the call to ResetCameraClippingRange to the end of vtkSMViewProxy::Update (https://github.com/Kitware/ParaView/blob/v5.7.0/ParaViewCore/ServerManager/Rendering/vtkSMViewProxy.cxx#L478). This gets called for the StillRender and the InteractiveRender. The only remaining way to call the Render function, is using the vtkPVRenderView::Select function. This shouldn't need a ResetCameraClippingRange, if thickness does not change due to selection.
I have tracked down the error using the following setup:
- Version 5.7
- Client connected to pvserver
- pvserver without GPU
- Loading big STL (300MB) file
- Reset camera using:
- view.CenterOfRotation = simple.GetActiveCamera().GetFocalPoint()
- Fast mouse movements (rotating the view) leads to:
- "Tag mismatch: got 1, expecting 10" on the pvserver side, which causes the server to shut down.