loleaflet/src/core/Socket.js | 15 +++- loleaflet/src/layer/tile/TileLayer.js | 16 +++- loleaflet/src/map/handler/Map.Keyboard.js | 3 loolwsd/.gitignore | 1 loolwsd/ClientSession.cpp | 3 loolwsd/DocumentBroker.cpp | 8 +- loolwsd/DocumentBroker.hpp | 4 + loolwsd/LOOLForKit.cpp | 12 +-- loolwsd/LOOLKit.cpp | 13 +-- loolwsd/LOOLWSD.cpp | 4 - loolwsd/protocol.txt | 5 - loolwsd/test/Makefile.am | 14 --- loolwsd/test/helpers.hpp | 3 loolwsd/test/test.cpp | 3 loolwsd/test/testlokit.cpp | 107 ------------------------------ 15 files changed, 61 insertions(+), 150 deletions(-)
New commits: commit 5dd3490b6255e2886559a50b0959bae1289c711d Author: Tor Lillqvist <t...@collabora.com> Date: Wed Oct 12 11:47:26 2016 +0300 Use std::getenv() consistently (cherry picked from commit 9fee650f437c58538d6cf486c4e77b5541cba50c) diff --git a/loolwsd/LOOLForKit.cpp b/loolwsd/LOOLForKit.cpp index 7a38541..735d0d7 100644 --- a/loolwsd/LOOLForKit.cpp +++ b/loolwsd/LOOLForKit.cpp @@ -199,10 +199,10 @@ int main(int argc, char** argv) } // Initialization - const bool logToFile = getenv("LOOL_LOGFILE"); - const char* logFilename = getenv("LOOL_LOGFILENAME"); - const char* logLevel = getenv("LOOL_LOGLEVEL"); - const char* logColor = getenv("LOOL_LOGCOLOR"); + const bool logToFile = std::getenv("LOOL_LOGFILE"); + const char* logFilename = std::getenv("LOOL_LOGFILENAME"); + const char* logLevel = std::getenv("LOOL_LOGLEVEL"); + const char* logColor = std::getenv("LOOL_LOGCOLOR"); std::map<std::string, std::string> logProperties; if (logToFile && logFilename) { @@ -220,11 +220,11 @@ int main(int argc, char** argv) std::string loTemplate; #if ENABLE_DEBUG - static const char* clientPort = getenv("LOOL_TEST_CLIENT_PORT"); + static const char* clientPort = std::getenv("LOOL_TEST_CLIENT_PORT"); if (clientPort) ClientPortNumber = std::stoi(clientPort); - static const char* masterPort = getenv("LOOL_TEST_MASTER_PORT"); + static const char* masterPort = std::getenv("LOOL_TEST_MASTER_PORT"); if (masterPort) MasterPortNumber = std::stoi(masterPort); #endif diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp index 089b695..d0c5826 100644 --- a/loolwsd/LOOLKit.cpp +++ b/loolwsd/LOOLKit.cpp @@ -13,15 +13,14 @@ #include <dlfcn.h> #include <ftw.h> -#include <climits> #include <malloc.h> -#include <cstdlib> #include <sys/capability.h> #include <unistd.h> #include <utime.h> #include <atomic> #include <cassert> +#include <climits> #include <condition_variable> #include <cstdlib> #include <iostream> @@ -1304,10 +1303,10 @@ void lokit_main(const std::string& childRoot, bool displayVersion) { // Reinitialize logging when forked. - const bool logToFile = getenv("LOOL_LOGFILE"); - const char* logFilename = getenv("LOOL_LOGFILENAME"); - const char* logLevel = getenv("LOOL_LOGLEVEL"); - const char* logColor = getenv("LOOL_LOGCOLOR"); + const bool logToFile = std::getenv("LOOL_LOGFILE"); + const char* logFilename = std::getenv("LOOL_LOGFILENAME"); + const char* logLevel = std::getenv("LOOL_LOGLEVEL"); + const char* logColor = std::getenv("LOOL_LOGCOLOR"); std::map<std::string, std::string> logProperties; if (logToFile && logFilename) { @@ -1370,7 +1369,7 @@ void lokit_main(const std::string& childRoot, // Copy (link) LO installation and other necessary files into it from the template. bool bLoopMounted = false; - if (getenv("LOOL_BIND_MOUNT")) + if (std::getenv("LOOL_BIND_MOUNT")) { Path usrSrcPath(sysTemplate, "usr"); Path usrDestPath(jailPath, "usr"); diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp index 79d1986..ec375ea 100644 --- a/loolwsd/LOOLWSD.cpp +++ b/loolwsd/LOOLWSD.cpp @@ -1803,11 +1803,11 @@ void LOOLWSD::handleOption(const std::string& optionName, else if (optionName == "careerspan") careerSpanSeconds = std::stoi(value); - static const char* clientPort = getenv("LOOL_TEST_CLIENT_PORT"); + static const char* clientPort = std::getenv("LOOL_TEST_CLIENT_PORT"); if (clientPort) ClientPortNumber = std::stoi(clientPort); - static const char* masterPort = getenv("LOOL_TEST_MASTER_PORT"); + static const char* masterPort = std::getenv("LOOL_TEST_MASTER_PORT"); if (masterPort) MasterPortNumber = std::stoi(masterPort); #endif diff --git a/loolwsd/test/helpers.hpp b/loolwsd/test/helpers.hpp index bed5788..5f5a5c1 100644 --- a/loolwsd/test/helpers.hpp +++ b/loolwsd/test/helpers.hpp @@ -10,6 +10,7 @@ #include "config.h" #include <algorithm> +#include <cstdlib> #include <condition_variable> #include <mutex> #include <thread> @@ -118,7 +119,7 @@ Poco::Net::HTTPClientSession* createSession(const Poco::URI& uri) inline std::string getTestServerURI() { - static const char* clientPort = getenv("LOOL_TEST_CLIENT_PORT"); + static const char* clientPort = std::getenv("LOOL_TEST_CLIENT_PORT"); static std::string serverURI( #if ENABLE_SSL diff --git a/loolwsd/test/test.cpp b/loolwsd/test/test.cpp index d93ccf9..7a081a9 100644 --- a/loolwsd/test/test.cpp +++ b/loolwsd/test/test.cpp @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include <cstdlib> #include <iostream> #include <cppunit/BriefTestProgressListener.h> @@ -25,7 +26,7 @@ class HTTPGetTest; bool filterTests(CPPUNIT_NS::TestRunner& runner, CPPUNIT_NS::Test* testRegistry) { - const char* envar = getenv("CPPUNIT_TEST_NAME"); + const char* envar = std::getenv("CPPUNIT_TEST_NAME"); if (envar) { std::string testName(envar); commit df6166bcb9abf0c5e1e5522d616452b6595d7d46 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 (cherry picked from commit f910dcbf88fa0b83a7f711f2a52d5f8dffe9da1c) 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 1c2332642fe50d60812a5a96dffe90fdd70e2a6f 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. (cherry picked from commit 2c744f75c6aabe21de5ad25c89aaa6874e77cb67) 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] commit 28c37e8d205d8cca2a941fc73eb052cfacd9d431 Author: Henry Castro <hcas...@collabora.com> Date: Tue Oct 11 08:26:02 2016 -0400 Revert "loolwsd: test: .uno:AutoSum" This is no longer need it, because the unit test was already added to sc/qa/unit/tiledrendering/tiledrendering.cxx This reverts commit 9b1087e000a5e1ca5ebf9e9c25c8a31705ce6795. (cherry picked from commit c3c8235561dabd6ed47dbeef19d076b785de5fee) diff --git a/loolwsd/.gitignore b/loolwsd/.gitignore index d2ff61f..d98297b 100644 --- a/loolwsd/.gitignore +++ b/loolwsd/.gitignore @@ -56,4 +56,3 @@ loolstress loolforkit-nocaps loadtest unittest -testlokit diff --git a/loolwsd/test/Makefile.am b/loolwsd/test/Makefile.am index 1cf21fe..70c073a 100644 --- a/loolwsd/test/Makefile.am +++ b/loolwsd/test/Makefile.am @@ -7,7 +7,7 @@ AUTOMAKE_OPTION = serial-tests # test: tests that need loolwsd running, and that are run via 'make check' check_PROGRAMS = test -noinst_PROGRAMS = test unittest testlokit +noinst_PROGRAMS = test unittest AM_CXXFLAGS = $(CPPUNIT_CFLAGS) @@ -46,10 +46,6 @@ unittest_CPPFLAGS = -I$(top_srcdir) -DBUILDING_TESTS unittest_SOURCES = TileQueueTests.cpp WhiteBoxTests.cpp test.cpp $(wsd_sources) unittest_LDADD = $(CPPUNIT_LIBS) -testlokit_CPPFLAGS = -DTDOC=\"$(abs_top_srcdir)/test/data\" -I$(top_srcdir) -DBUILDING_TESTS -testlokit_SOURCES = testlokit.cpp test.cpp $(wsd_sources) -testlokit_LDADD = $(CPPUNIT_LIBS) - # unit test modules: unit_fuzz_la_SOURCES = UnitFuzz.cpp unit_admin_la_SOURCES = UnitAdmin.cpp @@ -69,13 +65,7 @@ SYSTEM_STAMP = endif if HAVE_LO_PATH -check-lokit: testlokit - @echo - @echo "Running testlokit." - @echo - @JAIL_PATH="file://@JAILS_PATH@/user" LO_PATH="@LO_PATH@/program" ${top_builddir}/test/testlokit > check-lokit.log 2>&1 || { cat check-lokit.log ; exit 1 ; } - -check-local: check-lokit +check-local: ./run_unit.sh --log-file test.log --trs-file test.trs # FIXME unit-fonts.la is unstable, disabled for now. TESTS = unit-timeout.la unit-prefork.la unit-tilecache.la unit-admin.la unit-storage.la diff --git a/loolwsd/test/testlokit.cpp b/loolwsd/test/testlokit.cpp deleted file mode 100644 index 5d02c20..0000000 --- a/loolwsd/test/testlokit.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -#include "config.h" - -#include <mutex> -#include <cassert> -#include <memory> -#include <condition_variable> - -#define LOK_USE_UNSTABLE_API -#include <LibreOfficeKit/LibreOfficeKitInit.h> - -#include "LibreOfficeKit.hpp" - -#include <cppunit/extensions/HelperMacros.h> - -class TestLOKit : public CPPUNIT_NS::TestFixture -{ - std::shared_ptr<lok::Office> _loKit; - - CPPUNIT_TEST_SUITE(TestLOKit); - - CPPUNIT_TEST(testAutoSum); - - CPPUNIT_TEST_SUITE_END(); - - void testAutoSum(); - -public: - bool _readyCallback; - std::string _cellFormula; - std::condition_variable _cvCallback; - - TestLOKit() - { - char* userdir = getenv("JAIL_PATH"); - CPPUNIT_ASSERT_MESSAGE("JAIL_PATH env variable not set", userdir != nullptr); - - char* instdir = getenv("LO_PATH"); - CPPUNIT_ASSERT_MESSAGE("LO_PATH env variable not set", instdir != nullptr); - - _loKit = std::make_shared<lok::Office>(lok_init_2(instdir, userdir)); - if (!_loKit || !_loKit->get()) - { - CPPUNIT_FAIL("LibreOfficeKit initialization failed."); - } - } - - ~TestLOKit() - { - } - - static void ViewCallback(const int type, const char* payload, void* data) - { - if (data == nullptr) - { - CPPUNIT_FAIL("Data is nullptr"); - } - - TestLOKit* test = static_cast<TestLOKit*>(data); - - switch (type) - { - case LOK_CALLBACK_CELL_FORMULA: - { - test->_cellFormula = payload; - test->_readyCallback = true; - test->_cvCallback.notify_one(); - } - } - } - - void setUp() - { - } - - void tearDown() - { - } -}; - -void TestLOKit::testAutoSum() -{ - std::shared_ptr<lok::Document> doc = _loKit->documentLoad(TDOC"/empty.ods"); - CPPUNIT_ASSERT(doc); - - std::mutex mutex; - doc->initializeForRendering(""); - doc->registerCallback(ViewCallback, this); - doc->postUnoCommand(".uno:AutoSum"); - - std::unique_lock<std::mutex> lock(mutex); - _cvCallback.wait_for(lock, std::chrono::seconds(2), [this] { return _readyCallback; }); - doc->registerCallback(nullptr, nullptr); - CPPUNIT_ASSERT(_cellFormula.find("=SUM(") != std::string::npos); -} - -CPPUNIT_TEST_SUITE_REGISTRATION(TestLOKit); - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits