loleaflet/src/core/Socket.js              |   15 ++++++++++++---
 loleaflet/src/layer/tile/TileLayer.js     |   16 ++++++++++++++--
 loleaflet/src/map/handler/Map.Keyboard.js |    3 ---
 loolwsd/ClientSession.cpp                 |    3 ++-
 loolwsd/DocumentBroker.cpp                |    8 ++++++--
 loolwsd/DocumentBroker.hpp                |    4 ++++
 loolwsd/protocol.txt                      |    5 +++--
 7 files changed, 41 insertions(+), 13 deletions(-)

New commits:
commit f910dcbf88fa0b83a7f711f2a52d5f8dffe9da1c
Author: László Németh <laszlo.nem...@collabora.com>
Date:   Tue Oct 11 14:15:13 2016 +0200

    loleaflet: tile debug: show tile render count and cached tiles
    
    - show total number of the rendered tiles of the document, also
      the difference between the previous number in the client
    
    - show cached tiles in transparent yellow color (in debug build)
    
    - send ping messages after every invalidation message instead of
      keypressing
    
    - fix memory leak: remove unused leaflet rectangle overlays on the
      tiles

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index d26277d..34608e9 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -211,10 +211,13 @@ L.Socket = L.Class.extend({
                        }
                        this._map.fire('error', {msg: textMsg});
                }
-               else if (textMsg === 'pong' && this._map._docLayer && 
this._map._docLayer._debug) {
+               else if (textMsg.startsWith('pong ') && this._map._docLayer && 
this._map._docLayer._debug) {
                        var times = this._map._docLayer._debugTimePING;
-                       var timeText = 
this._map._docLayer._debugSetTimes(times, +new Date() - times.date);
-                       this._map._docLayer._debugDataPING.setPrefix('Server 
ping time: ' + timeText);
+                       var timeText = 
this._map._docLayer._debugSetTimes(times, +new Date() - 
this._map._docLayer._debugPINGQueue.shift());
+                       this._map._docLayer._debugDataPING.setPrefix('Server 
ping time: ' + timeText +
+                                       '. Rendered tiles: ' + 
command.rendercount +
+                                       ', last: ' + (command.rendercount - 
this._map._docLayer._debugRenderCount));
+                       this._map._docLayer._debugRenderCount = 
command.rendercount;
                }
                else if (textMsg.startsWith('statusindicator:')) {
                        //FIXME: We should get statusindicator when saving too, 
no?
@@ -417,6 +420,12 @@ L.Socket = L.Class.extend({
                        else if (tokens[i].substring(0, 7) === 'params=') {
                                command.params = 
tokens[i].substring(7).split(',');
                        }
+                       else if (tokens[i].substring(0, 9) === 'renderid=') {
+                               command.renderid = tokens[i].substring(9);
+                       }
+                       else if (tokens[i].substring(0, 12) === 'rendercount=') 
{
+                               command.rendercount = 
parseInt(tokens[i].substring(12));
+                       }
                }
                if (command.tileWidth && command.tileHeight && 
this._map._docLayer) {
                        var defaultZoom = this._map.options.zoom;
diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index 452a93c..9672459 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1027,7 +1027,11 @@ L.TileLayer = L.GridLayer.extend({
                                tile._debugPopup = L.popup({className: 'debug', 
offset: new L.Point(0, 0), autoPan: false, closeButton: false, closeOnClick: 
false})
                                                .setLatLng(new 
L.LatLng(tileBound.getSouth(), tileBound.getWest() + (tileBound.getEast() - 
tileBound.getWest())/5));
                                this._debugInfo.addLayer(tile._debugPopup);
+                               if (this._debugTiles[key]) {
+                                       
this._debugInfo.removeLayer(this._debugTiles[key]);
+                               }
                                tile._debugTile = L.rectangle(tileBound, 
{color: 'blue', weight: 1, fillOpacity: 0, pointerEvents: 'none'});
+                               this._debugTiles[key] = tile._debugTile;
                                tile._debugTime = this._debugGetTimeArray();
                                this._debugInfo.addLayer(tile._debugTile);
                        }
@@ -1038,7 +1042,7 @@ L.TileLayer = L.GridLayer.extend({
                                                '<br>' + 
this._debugSetTimes(tile._debugTime, +new Date() - 
tile._debugTime.date).replace(/, /g, '<br>'));
                        }
                        if (tile._debugTile) {
-                               tile._debugTile.setStyle({fillOpacity: 0});
+                               tile._debugTile.setStyle({fillOpacity: 
(command.renderid === 'cached') ? 0.1 : 0, fillColor: 'yellow' });
                        }
                        this._debugShowTileData();
                }
@@ -1826,6 +1830,7 @@ L.TileLayer = L.GridLayer.extend({
                if (this._debug) {
                        this._debugInfo = new L.LayerGroup();
                        map.addLayer(this._debugInfo);
+                       this._debugTiles = {};
                        this._debugInvalidBounds = {};
                        this._debugInvalidBoundsMessage = {};
                        this._debugTimeout();
@@ -1833,6 +1838,7 @@ L.TileLayer = L.GridLayer.extend({
                        this._debugCancelledTiles = 0;
                        this._debugLoadCount = 0;
                        this._debugInvalidateCount = 0;
+                       this._debugRenderCount = 0;
                        if (!this._debugDataTileCombine) {
                                this._debugDataTileCombine = 
L.control.attribution({prefix: '', position: 'bottomleft'}).addTo(map);
                                this._debugDataFromKeyInputToInvalidate = 
L.control.attribution({prefix: '', position: 'bottomleft'}).addTo(map);
@@ -1841,6 +1847,7 @@ L.TileLayer = L.GridLayer.extend({
 
                        }
                        this._debugTimePING = this._debugGetTimeArray();
+                       this._debugPINGQueue = [];
                        this._debugTimeKeypress = this._debugGetTimeArray();
                        this._debugKeypressQueue = [];
                }
@@ -1874,11 +1881,16 @@ L.TileLayer = L.GridLayer.extend({
                        var timeText = 
this._debugSetTimes(this._debugTimeKeypress, now - oldestKeypress);
                        
this._debugDataFromKeyInputToInvalidate.setPrefix('Elapsed time between key 
input and next invalidate: ' + timeText);
                }
+
+               // query server ping time after invalidation messages
+               // pings will be paired with the pong messages
+               this._debugPINGQueue.push(+new Date());
+               this._map._socket.sendMessage('ping');
        },
 
        _debugAddInvalidationData: function(tile) {
                if (tile._debugTile) {
-                       tile._debugTile.setStyle({fillOpacity: 0.5});
+                       tile._debugTile.setStyle({fillOpacity: 0.5, fillColor: 
'blue'});
                        tile._debugTime.date = +new Date();
                        tile._debugInvalidateCount++;
                        this._debugInvalidateCount++;
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js 
b/loleaflet/src/map/handler/Map.Keyboard.js
index 5872247..b441534 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -314,9 +314,6 @@ L.Map.Keyboard = L.Handler.extend({
                                        unoKeyCode = 
this._toUNOKeyCode(keyCode);
                                }
                                if (docLayer._debug) {
-                                       // query server ping time at key press
-                                       this._map._docLayer._debugTimePING.date 
= +new Date();
-                                       this._map._socket.sendMessage('ping');
                                        // key press times will be paired with 
the invalidation messages
                                        docLayer._debugKeypressQueue.push(+new 
Date());
                                }
commit 2c744f75c6aabe21de5ad25c89aaa6874e77cb67
Author: László Németh <laszlo.nem...@collabora.com>
Date:   Tue Oct 11 14:39:56 2016 +0200

    loolwsd: count rendered tiles and serve the number for debugging
    
    extend the 'pong' server message with the data "rendercount=num",
    where "num" is the total number of rendered tiles of the document.

diff --git a/loolwsd/ClientSession.cpp b/loolwsd/ClientSession.cpp
index f3acf98..6e8a60e 100644
--- a/loolwsd/ClientSession.cpp
+++ b/loolwsd/ClientSession.cpp
@@ -152,7 +152,8 @@ bool ClientSession::_handleInput(const char *buffer, int 
length)
     }
     else if (tokens[0] == "ping")
     {
-        sendTextFrame("pong");
+        std::string count = std::to_string(_docBroker->getRenderedTileCount());
+        sendTextFrame("pong rendercount=" + count);
         return true;
     }
     else if (tokens[0] == "renderfont")
diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 4e7e618..3189944 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -117,7 +117,8 @@ DocumentBroker::DocumentBroker() :
     _cursorHeight(0),
     _mutex(),
     _saveMutex(),
-    _tileVersion(0)
+    _tileVersion(0),
+    _debugRenderedTileCount(0)
 {
     Log::info("Empty DocumentBroker (marked to destroy) created.");
 }
@@ -142,7 +143,8 @@ DocumentBroker::DocumentBroker(const Poco::URI& uriPublic,
     _cursorHeight(0),
     _mutex(),
     _saveMutex(),
-    _tileVersion(0)
+    _tileVersion(0),
+    _debugRenderedTileCount(0)
 {
     assert(!_docKey.empty());
     assert(!_childRoot.empty());
@@ -552,6 +554,7 @@ void DocumentBroker::handleTileRequest(TileDesc& tile,
     Log::debug() << "Sending render request for tile (" << tile.getPart() << 
',' << tile.getTilePosX() << ',' << tile.getTilePosY() << ")." << Log::end;
     const std::string request = "tile " + tile.serialize();
     _childProcess->getWebSocket()->sendFrame(request.data(), request.size());
+    _debugRenderedTileCount++;
 }
 
 void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined,
@@ -597,6 +600,7 @@ void 
DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined,
             tile.setVersion(++_tileVersion);
             tileCache().subscribeToTileRendering(tile, session);
             tiles.push_back(tile);
+            _debugRenderedTileCount++;
         }
     }
 
diff --git a/loolwsd/DocumentBroker.hpp b/loolwsd/DocumentBroker.hpp
index d8ccee4..186b174 100644
--- a/loolwsd/DocumentBroker.hpp
+++ b/loolwsd/DocumentBroker.hpp
@@ -234,6 +234,8 @@ public:
     /// Forward a message from client session to its respective child session.
     bool forwardToChild(const std::string& viewId, const char *buffer, int 
length);
 
+    int getRenderedTileCount() { return _debugRenderedTileCount; }
+
 private:
 
     /// Sends the .uno:Save command to LoKit.
@@ -275,6 +277,8 @@ private:
     /// painting and invalidation.
     std::atomic<size_t> _tileVersion;
 
+    int _debugRenderedTileCount;
+
     static constexpr auto IdleSaveDurationMs = 30 * 1000;
     static constexpr auto AutoSaveDurationMs = 300 * 1000;
 };
diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt
index ba91ae0..3aaa840 100644
--- a/loolwsd/protocol.txt
+++ b/loolwsd/protocol.txt
@@ -241,9 +241,10 @@ nextmessage: size=<byteSize>
     must be handled by clients that cannot (like those using Poco
     1.6.0.
 
-pong
+pong rendercount=<num>
 
-    sent in reply to a 'ping' message
+    sent in reply to a 'ping' message, where <num> is the total number
+    of rendered tiles of the document.
 
 status: type=<typeName> parts=<numberOfParts> current=<currentPartNumber> 
width=<width> height=<height> viewid=<viewId> [partNames]
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to