« Previous | Next »

RFB on Pharo 3

01 May 2014

Getting RFB to work is always an adventure. On the newly released Pharo 3.0, RFB installs cleanly:

Gofer new
    smalltalkhubUser: 'PharoExtras' project: 'RFB';
    package: 'ConfigurationOfRFB';
    load.
(ConfigurationOfRFB project version: #stable) load.

However, running the VNC Server GUI results in "MessageNotUnderstood: UpdatingMenuItemMorph>>wordingProvider:wordingSelector:".

Never mind, let's run it programmatically:

RFBServer current
    initializePreferences;
    configureForMemoryConservation;
    allowEmptyPasswords: false;
    setFullPassword: 'abc123'; "Clear text passwords..."
    setViewPassword: 'abc123456!'; "... urgh!"
    enableLogging: true;
    enableDebugging: true;
    start: 0.

RFBServer current isRunning.  true

Start the Pharo VM process (on an X-less Ubuntu 14.04 server):

% pharo -vm-display-none -vm-sound-none pharo.image &

Connect via COTVNC, try stuff... Wait, what, it froze? Close VNC connection, reconnect, and we have a debugger. Drag the debugger window... froze again. Close VNC connection, reconnect, and the debugger window is in the dragged-to position. The debugger window shows that, in this particular invocation of RFBFramebufferUpdateRectHeader>>unsignedShortAt:put:bigEndian:, the parameter value is a Float.

As the VNC connection keeps freezing, it was not possible to debug this remotely via VNC. So it is time to switch back to regular desktop Pharo.

After a bit of experimentation, this change in RFBFramebufferUpdateRectHeader>>bounds:type: seems to fix the problem:

bounds: aRect type: type
    "Set the contents of the receiver to represent a rectangle of the specified type."
    | left top width height aBlock |

    aBlock := [ :v | (v isFloat) ifTrue: [ v truncated ] ifFalse: [ v ] ].	
    left := aBlock value: aRect left.
    top := aBlock value: aRect top.
    width := aBlock value: aRect width.
    height := aBlock value: aRect height.

    self
        unsignedShortAt: 1 put: left;
        unsignedShortAt: 3 put: top;
        unsignedShortAt: 5 put: width;
        unsignedShortAt: 7 put: height;
        unsignedLongAt: 9 put: type

Once again, I have working VNC into Pharo running on an X-less server. Yay.

What about the clear text passwords? That's what SpsSplitPasswordStore is for:

RFBServer current
    initializePreferences;
    configureForMemoryConservation;
    allowEmptyPasswords: false;
    setFullPassword: (SpsSplitPasswordStore readFrom: 'spsrw.dat');
    setViewPassword: (SpsSplitPasswordStore readFrom: 'spsro.dat');
    enableLogging: true;
    enableDebugging: true;
    start: 0.
Tags: RFB, VNC