vnc2video icon indicating copy to clipboard operation
vnc2video copied to clipboard

Move Canvas and Renderer initialization to DefaultClientServerInitHandler

Open gyuchang opened this issue 4 years ago • 0 comments

The nil pointer deference errors described in #11 and #12 were caused by canvas and renderers not being properly initialized/configured.

  1. In example/client/main.go, renderers are configured after ffmpeg is started. https://github.com/amitbet/vnc2video/blob/9d50b9dab1d92afd6c71ca5ccc5157135c121428/example/client/main.go#L89-L95
  2. But the VNC message handlers are started during the Connect call. https://github.com/amitbet/vnc2video/blob/9d50b9dab1d92afd6c71ca5ccc5157135c121428/example/client/main.go#L60
  3. This means that RemoveCursor/PaintCursor (which requires renderers to be linked with canvas) in DefaultClientMessageHandler could be called before the renderers are ready (by .SetTargetImage(screenImage) in step 1) https://github.com/amitbet/vnc2video/blob/9d50b9dab1d92afd6c71ca5ccc5157135c121428/client.go#L302-L306

#12 proposed that RemoveCursort should ignore missing canvas, but a more fundamental fix is to perform the renderer configuration in DefaultClientServerInitHandler right after the size of the canvas is known.

gyuchang avatar May 08 '20 06:05 gyuchang