diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp index 0320de169..0dee49507 100644 --- a/loolwsd/MasterProcessSession.cpp +++ b/loolwsd/MasterProcessSession.cpp @@ -7,6 +7,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "config.h" + #include #include #include @@ -572,16 +574,22 @@ void MasterProcessSession::sendTile(const char *buffer, int length, StringTokeni return; } - const std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()) + "\n"; - - std::vector output; - output.reserve(4 * width * height); - output.resize(response.size()); - std::memcpy(output.data(), response.data(), response.size()); - std::unique_ptr cachedTile = _docBroker->tileCache().lookupTile(part, width, height, tilePosX, tilePosY, tileWidth, tileHeight); + if (cachedTile) { + std::string response = "tile: " + Poco::cat(std::string(" "), tokens.begin() + 1, tokens.end()); + +#if ENABLE_DEBUG + response += " renderid=cached"; +#endif + response += "\n"; + + std::vector output; + output.reserve(4 * width * height); + output.resize(response.size()); + std::memcpy(output.data(), response.data(), response.size()); + assert(cachedTile->is_open()); cachedTile->seekg(0, std::ios_base::end); size_t pos = output.size(); @@ -691,6 +699,10 @@ void MasterProcessSession::sendCombinedTiles(const char* /*buffer*/, int /*lengt oss << " timestamp=" << reqTimestamp; } +#if ENABLE_DEBUG + oss << " renderid=cached"; +#endif + oss << "\n"; const std::string response = oss.str(); diff --git a/loolwsd/protocol.txt b/loolwsd/protocol.txt index 2c7944574..1d2324da9 100644 --- a/loolwsd/protocol.txt +++ b/loolwsd/protocol.txt @@ -237,9 +237,10 @@ tile: part= width= height= tileposx= tileposy=< The parameters from the corresponding 'tile' command. - Additionally, in a debug build, the renderid is a unique + Additionally, in a debug build, the renderid is either a unique identifier, different for each actual call to LibreOfficeKit to - render a tile. + render a tile, or the string 'cached' if the tile was found in the + cache. Each LOK_CALLBACK_FOO_BAR callback causes a corresponding message to the client, consisting of the FOO_BAR part in lowercase, without