[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - test/TileCacheTests.cpp wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/TestStubs.cpp

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Oct 1 10:47:27 UTC 2018


 test/TileCacheTests.cpp |   78 ++++++++++++++++++++++++++++++++++++++++++++++++
 wsd/ClientSession.cpp   |   35 +++++++++++++++++++++
 wsd/ClientSession.hpp   |   20 ------------
 wsd/TestStubs.cpp       |    2 +
 4 files changed, 116 insertions(+), 19 deletions(-)

New commits:
commit 76aa5e07958dc297001a36b26b3d0069f5da4089
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Sep 26 22:15:37 2018 +0200
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Mon Oct 1 12:47:09 2018 +0200

    Filter out tiles by wired on wsd side too
    
    Some times tiles with the same wireID survives the wireID
    filtering in kit, so we should do that in wsd too.
    The issue is with the tilesBeingRendered construction. First when
    one tile is filtered out on kit side the client remains subcribed
    to the tile, since wsd does not know filtering happened.
    Second via the tilesBeingRendered object more clients can be subcribed
    to the same tile and so when one client request a new version of this
    tile (with an old wireID) the rendered tile is sent to all subscribed
    clients even if the other clients has up-to-date tiles.
    
    (cherry picked from commit 9683f53a9c81dfcb9624705cbeeed48ec426ca3b)
    
    Change-Id: I4ca6b7a83a5d6979a9f924d766a71aba5e5362c7
    Reviewed-on: https://gerrit.libreoffice.org/61127
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/test/TileCacheTests.cpp b/test/TileCacheTests.cpp
index 2c8f241d8..535bafc30 100644
--- a/test/TileCacheTests.cpp
+++ b/test/TileCacheTests.cpp
@@ -80,6 +80,7 @@ class TileCacheTests : public CPPUNIT_NS::TestFixture
     //CPPUNIT_TEST(testTileInvalidatePartCalc);
     //CPPUNIT_TEST(testTileInvalidatePartImpress);
     CPPUNIT_TEST(testTileBeingRenderedHandling);
+    CPPUNIT_TEST(testWireIDFilteringOnWSDSide);
 
     CPPUNIT_TEST_SUITE_END();
 
@@ -104,6 +105,7 @@ class TileCacheTests : public CPPUNIT_NS::TestFixture
     void testTileInvalidatePartCalc();
     void testTileInvalidatePartImpress();
     void testTileBeingRenderedHandling();
+    void testWireIDFilteringOnWSDSide();
 
     void checkTiles(std::shared_ptr<LOOLWebSocket>& socket,
                     const std::string& type,
@@ -1204,6 +1206,82 @@ void TileCacheTests::testTileBeingRenderedHandling()
     }
 }
 
+void TileCacheTests::testWireIDFilteringOnWSDSide()
+{
+    const char* testname = "testWireIDFilteringOnWSDSide ";
+
+    std::string documentPath, documentURL;
+    getDocumentPathAndURL("empty.odt", documentPath, documentURL, testname);
+    std::shared_ptr<LOOLWebSocket> socket1 = loadDocAndGetSocket(_uri, documentURL, testname);
+    // Set the client visible area
+    sendTextFrame(socket1, "clientvisiblearea x=-4005 y=0 width=50490 height=72300");
+    sendTextFrame(socket1, "clientzoom tilepixelwidth=256 tilepixelheight=256 tiletwipwidth=3840 tiletwipheight=3840");
+
+    std::shared_ptr<LOOLWebSocket> socket2 = loadDocAndGetSocket(_uri, documentURL, testname, true);
+    // Set the client visible area
+    sendTextFrame(socket1, "clientvisiblearea x=-4005 y=0 width=50490 height=72300");
+    sendTextFrame(socket1, "clientzoom tilepixelwidth=256 tilepixelheight=256 tiletwipwidth=3840 tiletwipheight=3840");
+
+    //1. First make the first client to trigger the kit to filter out tiles based on identical wireIDs
+
+    // Type one character to trigger invalidation
+    sendChar(socket1, 'x', skNone, testname);
+
+    // First wsd forwards the invalidation
+    assertResponseString(socket1, "invalidatetiles:", testname);
+
+    // For the first input wsd will send all invalidated tiles
+    int arrivedTiles = 0;
+    bool gotTile = false;
+    do
+    {
+        std::vector<char> tile = getResponseMessage(socket1, "tile:", testname);
+        gotTile = !tile.empty();
+        if(gotTile)
+            ++arrivedTiles;
+    } while(gotTile);
+
+    CPPUNIT_ASSERT_MESSAGE("We expect two tiles at least!", arrivedTiles > 1);
+
+    // Type an other character
+    sendChar(socket1, 'x', skNone, testname);
+    assertResponseString(socket1, "invalidatetiles:", testname);
+
+    // For the second input wsd will send one tile, since other tiles are indentical
+    arrivedTiles = 0;
+    gotTile = false;
+    do
+    {
+        std::vector<char> tile = getResponseMessage(socket1, "tile:", testname);
+        gotTile = !tile.empty();
+        if(gotTile)
+            ++arrivedTiles;
+    } while(gotTile);
+
+    CPPUNIT_ASSERT_EQUAL(1, arrivedTiles);
+
+    //2. Now request the same tiles by the other client (e.g. scroll to the same view)
+
+    sendTextFrame(socket2, "tilecombine part=0 width=256 height=256 tileposx=0,3840,7680 tileposy=0,0,0 tilewidth=3840 tileheight=3840");
+
+    // We expect three tiles sent to the second client
+    arrivedTiles = 0;
+    gotTile = false;
+    do
+    {
+        std::vector<char> tile = getResponseMessage(socket2, "tile:", testname);
+        gotTile = !tile.empty();
+        if(gotTile)
+            ++arrivedTiles;
+    } while(gotTile);
+
+    CPPUNIT_ASSERT_EQUAL(3, arrivedTiles);
+
+    // wsd should not send tiles messages for the first client
+    std::vector<char> tile = getResponseMessage(socket1, "tile:", testname);
+    CPPUNIT_ASSERT_MESSAGE("Not expected tile message arrived!", tile.empty());
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(TileCacheTests);
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index eb8414ff5..8a4bb18cd 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1019,6 +1019,41 @@ bool ClientSession::forwardToClient(const std::shared_ptr<Message>& payload)
     return true;
 }
 
+void ClientSession::enqueueSendMessage(const std::shared_ptr<Message>& data)
+{
+    const std::shared_ptr<DocumentBroker> docBroker = _docBroker.lock();
+    // If in the correct thread - no need for wakeups.
+    if (docBroker)
+        docBroker->assertCorrectThread();
+
+    const std::string command = data->firstToken();
+    if (command == "tile:")
+    {
+        // Avoid sending tile if it has the same wireID as the previously sent tile
+        const TileDesc tile = TileDesc::parse(data->firstLine());
+        const std::string tileID = generateTileID(tile);
+        auto iter = _oldWireIds.find(tileID);
+        if(iter != _oldWireIds.end() && tile.getWireId() != 0 && tile.getWireId() == iter->second)
+        {
+            LOG_INF("WSD filters out a tile with the same wireID: " <<  tile.serialize("tile:"));
+            return;
+        }
+    }
+
+    LOG_TRC(getName() << " enqueueing client message " << data->id());
+    size_t sizeBefore = _senderQueue.size();
+    size_t newSize = _senderQueue.enqueue(data);
+
+    // Track sent tile
+    if (command == "tile:")
+    {
+        const TileDesc tile = TileDesc::parse(data->firstLine());
+        traceTileBySend(tile, sizeBefore == newSize);
+        if (sizeBefore != newSize)
+            LOG_INF("Sending new tile to client: " <<  tile.serialize("tile:"));
+    }
+}
+
 Authorization ClientSession::getAuthorization() const
 {
     Poco::URI::QueryParameters queryParams = _uriPublic.getQueryParameters();
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 67664ee35..38da74801 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -78,25 +78,7 @@ public:
         return true;
     }
 
-    void enqueueSendMessage(const std::shared_ptr<Message>& data)
-    {
-        const auto docBroker = _docBroker.lock();
-        // If in the correct thread - no need for wakeups.
-        if (docBroker)
-            docBroker->assertCorrectThread();
-
-        LOG_TRC(getName() << " enqueueing client message " << data->id());
-        size_t sizeBefore = _senderQueue.size();
-        size_t newSize = _senderQueue.enqueue(data);
-
-        // Track sent tile
-        const std::string command = data->firstToken();
-        if (command == "tile:")
-        {
-            const TileDesc tile = TileDesc::parse(data->firstLine());
-            traceTileBySend(tile, sizeBefore == newSize);
-        }
-    }
+    void enqueueSendMessage(const std::shared_ptr<Message>& data);
 
     /// Set the save-as socket which is used to send convert-to results.
     void setSaveAsSocket(const std::shared_ptr<StreamSocket>& socket)
diff --git a/wsd/TestStubs.cpp b/wsd/TestStubs.cpp
index 9a56e0a67..659d8476d 100644
--- a/wsd/TestStubs.cpp
+++ b/wsd/TestStubs.cpp
@@ -28,4 +28,6 @@ void ClientSession::traceUnSubscribeToTile(const std::string& /*tileCacheName*/)
 
 void ClientSession::clearTileSubscription() {};
 
+void ClientSession::enqueueSendMessage(const std::shared_ptr<Message>& /*data*/) {};
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list