loleaflet/src/layer/tile/TileLayer.js | 3 +- wsd/ClientSession.cpp | 37 +++++++++++++++++++++++----------- wsd/ClientSession.hpp | 7 +++--- wsd/DocumentBroker.cpp | 14 ++---------- wsd/protocol.txt | 2 - 5 files changed, 36 insertions(+), 27 deletions(-)
New commits: commit fee9f1fc1cb1ec5da184374e67b1328b3fd749c3 Author: Tamás Zolnai <[email protected]> Date: Wed Jun 13 16:21:48 2018 +0200 Removed these printout lines used for debugging Change-Id: Id87def8c69a15077bee47ab02c67e0995aeb0a12 diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 7271d3d25..dda63f52e 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1288,7 +1288,6 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined, std::unique_lock<std::mutex> lock(_mutex); LOG_TRC("TileCombined request for " << tileCombined.serialize()); - std::cerr << "handleTileCombinedRequest: " << std::endl; // Check which newly requested tiles needs rendering. std::vector<TileDesc> tilesNeedsRendering; @@ -1309,7 +1308,6 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined, // Send rendering request, prerender before we actually send the tiles if (!tilesNeedsRendering.empty()) { - std::cerr << "tilesNeedsRendering.size(): " << tilesNeedsRendering.size() << std::endl; TileCombined newTileCombined = TileCombined::create(tilesNeedsRendering); // Forward to child to render. @@ -1374,15 +1372,12 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se session->setTilesOnFly(requestedTiles.get()); // Satisfy as many tiles from the cache. - std::cerr << "requestedTiles.size(): " << requestedTiles.get().getTiles().size() << std::endl; std::vector<TileDesc> tilesNeedsRendering; for (auto& tile : requestedTiles.get().getTiles()) { - std::cerr << "alma: "<< std::endl; std::unique_ptr<std::fstream> cachedTile = _tileCache->lookupTile(tile); if (cachedTile) { - std::cerr << "cachedTile: "<< std::endl; //TODO: Combine the response to reduce latency. #if ENABLE_DEBUG const std::string response = tile.serialize("tile:") + " renderid=cached\n"; @@ -1408,7 +1403,6 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se } else { - std::cerr << "not cachedTile: "<< std::endl; // Not cached, needs rendering. if(tile.getVersion() == -1) // Rendering of this tile was not requested yet { @@ -1417,7 +1411,6 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se _debugRenderedTileCount++; } tileCache().subscribeToTileRendering(tile, session); - std::cerr << "not cachedTile2: "<< std::endl; } } commit 454a6307ee9e6ad0b116994aafee24472245c8da Author: Tamás Zolnai <[email protected]> Date: Wed Jun 13 15:04:09 2018 +0200 Store sent tiles's id instead of using a simple counter Change-Id: I8cbf84923a53fb6b294bd4039eb7382326f8c445 diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 1dcdf8df6..dbd1b0871 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1430,7 +1430,8 @@ L.TileLayer = L.GridLayer.extend({ L.Log.log(textMsg, L.INCOMING, key); // Send acknowledgment, that the tile message arrived - this._map._socket.sendMessage('tileprocessed tile= ' + key); + var tileID = command.part + ':' + command.x + ':' + command.y + ':' + command.tileWidth + ':' + command.tileHeight; + this._map._socket.sendMessage('tileprocessed tile=' + tileID); }, _tileOnLoad: function (done, tile) { diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 4d1c5c0e5..9a9762dcb 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -12,6 +12,7 @@ #include "ClientSession.hpp" #include <fstream> +#include <sstream> #include <Poco/Net/HTTPResponse.h> #include <Poco/StringTokenizer.h> @@ -47,8 +48,7 @@ ClientSession::ClientSession(const std::string& id, _tileWidthPixel(0), _tileHeightPixel(0), _tileWidthTwips(0), - _tileHeightTwips(0), - _tilesOnFly(0) + _tileHeightTwips(0) { const size_t curConnections = ++LOOLWSD::NumConnections; LOG_INF("ClientSession ctor [" << getName() << "], current number of connections: " << curConnections); @@ -327,13 +327,20 @@ bool ClientSession::_handleInput(const char *buffer, int length) } else if (tokens[0] == "tileprocessed") { - if(_tilesOnFly > 0) // canceltiles message can zero this value + std::string tileID; + if (tokens.size() != 2 || + !getTokenString(tokens[1], "tile", tileID)) { - --_tilesOnFly; - if(_tilesOnFly == 0) - { - _tileCounterStartTime = boost::none; - } + sendTextFrame("error: cmd=tileprocessed kind=syntax"); + return false; + } + auto iter = std::find(_tilesOnFly.begin(), _tilesOnFly.end(), tileID); + if(iter != _tilesOnFly.end()) + _tilesOnFly.erase(iter); + + if(_tilesOnFly.empty()) + { + _tileCounterStartTime = boost::none; } docBroker->sendRequestedTiles(shared_from_this()); return true; @@ -970,15 +977,23 @@ Authorization ClientSession::getAuthorization() const return Authorization(); } -void ClientSession::setTilesOnFly(int tilesOnFly) +void ClientSession::setTilesOnFly(boost::optional<TileCombined> tiles) { - _tilesOnFly = tilesOnFly; - if(tilesOnFly == 0) + + _tilesOnFly.clear(); + if(tiles == boost::none) { _tileCounterStartTime = boost::none; } else { + for (auto& tile : tiles.get().getTiles()) + { + std::ostringstream tileID; + tileID << tile.getPart() << ":" << tile.getTilePosX() << ":" << tile.getTilePosY() << ":" + << tile.getTileWidth() << ":" << tile.getTileHeight(); + _tilesOnFly.push_back(tileID.str()); + } _tileCounterStartTime = std::chrono::steady_clock::now(); } } diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp index abd535891..ed8266bbc 100644 --- a/wsd/ClientSession.hpp +++ b/wsd/ClientSession.hpp @@ -18,6 +18,7 @@ #include <Poco/URI.h> #include <Rectangle.hpp> #include <boost/optional.hpp> +#include <vector> class DocumentBroker; @@ -109,8 +110,8 @@ public: boost::optional<TileCombined>& getRequestedTiles() { return _requestedTiles; } - int getTilesOnFly() const { return _tilesOnFly; } - void setTilesOnFly(int tilesOnFly); + const std::vector<std::string>& getTilesOnFly() const { return _tilesOnFly; } + void setTilesOnFly(boost::optional<TileCombined> tiles); private: @@ -196,7 +197,7 @@ private: // Type of the docuemnt, extracter from status message std::string _docType; - int _tilesOnFly; + std::vector<std::string> _tilesOnFly; boost::optional<std::chrono::time_point<std::chrono::steady_clock>> _tileCounterStartTime; boost::optional<TileCombined> _requestedTiles; diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 6947eb7f3..7271d3d25 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -1364,15 +1364,14 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined, void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& session) { - assert(session->getTilesOnFly() >= 0); std::unique_lock<std::mutex> lock(_mutex); // All tiles were processed on client side what we sent last time, so we can send a new banch of tiles // which was invalidated / requested in the meantime boost::optional<TileCombined>& requestedTiles = session->getRequestedTiles(); - if(session->getTilesOnFly() == 0 && requestedTiles != boost::none && !requestedTiles.get().getTiles().empty()) + if(session->getTilesOnFly().empty() && requestedTiles != boost::none && !requestedTiles.get().getTiles().empty()) { - session->setTilesOnFly(requestedTiles.get().getTiles().size()); + session->setTilesOnFly(requestedTiles.get()); // Satisfy as many tiles from the cache. std::cerr << "requestedTiles.size(): " << requestedTiles.get().getTiles().size() << std::endl; @@ -1442,7 +1441,7 @@ void DocumentBroker::cancelTileRequests(const std::shared_ptr<ClientSession>& se std::unique_lock<std::mutex> lock(_mutex); // Clear tile requests - session->setTilesOnFly(0); + session->setTilesOnFly(boost::none); session->getRequestedTiles() = boost::none; const std::string canceltiles = tileCache().cancelTiles(session); diff --git a/wsd/protocol.txt b/wsd/protocol.txt index c7a126670..7c8d7e6a2 100644 --- a/wsd/protocol.txt +++ b/wsd/protocol.txt @@ -34,7 +34,7 @@ canceltiles tileprocessed tile=<tileid> Previously sent tile (server -> client) arrived and processed by the client. - Tileid has the next stucture : <tile x coord>:<tile y coord>:<zoom level>:<selected part> + Tileid has the next stucture : <selected part>:<tile x coord>:<tile y coord>:<tile width in twips>:<tile height in twips> downloadas name=<fileName> id=<id> format=<document format> options=<SkipImages, etc> _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
