- Javascript remote desktop bugfix

Tonight, I have been trying to fix a bug in one of the key features of MeshCentral, the Javascript remote desktop feature. MeshCentral can get access to computers even inside private networks which makes it useful, but it's even better because you can start a remote desktop session directly from the web site using any HTML5 browser (Firefox, Chrome, Safari...). Well, one of the bugs I noticed a while back was that screen "tiles" where not being drawn in the same order received in the browser. We would send tiles 1,2,3,4... and the browser would draw 1,3,2,4... This reordering often does not lead to any problems because most tiles don't overlap and the re-ordering is occasional. This said, there was a situation where re-ordering made a huge difference. When tiles where followed by "copy" operations, that copy one tile on the screen to a different part of the screen. In these cases, if the source tile is not right, the copy will be wrong and it can lead to a cascade a garbage on the screen. In the end, you have to process and execute the draw and copy operations in the same order received.

So the key to the problem is that when we get the image tile binary data, we tell the browser to decode it and call back into the javascript then the image is ready. If we get 10 tiles in a row, the browser may not decode them in the same order and the callback sometimes is out of order. Tonight, I added code to handle this situation and keep tiles that are our of order in a temporary array until operations can be performed in order. The result is flawless desktop remoting in Javascript.

Work on this feature is far from done, the software in the agent is very basic and even basic optimizations have not been done yet. In general, the remote desktop feature is slow but works well especially on computers with small displays. Hopefully we will get around to start optimizing soon...