[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - kit/Kit.cpp wsd/DocumentBroker.cpp wsd/TileCache.cpp

2020-08-11 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp|   12 +---
 wsd/DocumentBroker.cpp |2 +-
 wsd/TileCache.cpp  |   24 +---
 3 files changed, 23 insertions(+), 15 deletions(-)

New commits:
commit cfbb8d56272c9834dc2c416221b00d139b5406ad
Author: Michael Meeks 
AuthorDate: Fri Aug 7 18:37:53 2020 +0100
Commit: Jan Holesovsky 
CommitDate: Tue Aug 11 19:03:46 2020 +0200

Notify WSD of tiles which we didn't need to render.

When we get a wid match, this helps WSD to cleanup its tile
subscriber list effectively.

Change-Id: I6517039fb3d8c9ad8f53aef549b8adbb79961ce1
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100348
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/100507
Reviewed-by: Jan Holesovsky 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 09b003efc..1eb0ab03f 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1094,6 +1094,9 @@ public:
 // The tile content is identical to what the client already 
has, so skip it
 LOG_TRC("Match for tile #" << tileIndex << " at (" << 
positionX << ',' <<
 positionY << ") oldhash==hash (" << hash << "), 
wireId: " << wireId << " skipping");
+// Push a zero byte image to inform WSD we didn't need that.
+// This allows WSD side TileCache to free up waiting 
subscribers.
+pushRendered(renderedTiles, tiles[tileIndex], wireId, 0);
 tileIndex++;
 continue;
 }
@@ -1165,13 +1168,16 @@ public:
 tileIndex++;
 }
 
+// empty ones come first
+size_t zeroCheckStart = renderedTiles.size();
+
 _pngPool.run();
 
-for (auto  : renderedTiles)
+for (size_t i = zeroCheckStart; i < renderedTiles.size(); ++i)
 {
-if (i.getImgSize() == 0)
+if (renderedTiles[i].getImgSize() == 0)
 {
-LOG_ERR("Encoded 0-sized tile!");
+LOG_TRC("Encoded 0-sized tile in slot !" << i);
 assert(!"0-sized tile enocded!");
 }
 }
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 03f23c08a..05bd288f8 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1992,7 +1992,7 @@ void DocumentBroker::handleTileCombinedResponse(const 
std::vector& payload
 try
 {
 const size_t length = payload.size();
-if (firstLine.size() < static_cast(length) - 1)
+if (firstLine.size() <= static_cast(length) - 
1)
 {
 const TileCombined tileCombined = TileCombined::parse(firstLine);
 const char* buffer = payload.data();
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index e1cdefe8d..982cd985b 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -175,19 +175,24 @@ void TileCache::saveTileAndNotify(const TileDesc& tile, 
const char *data, const
 {
 assertCorrectThread();
 
-// Save to disk.
+if (size > 0)
+{
+// Save to in-memory cache.
 
-// Ignore if we can't save the tile, things will work anyway, but slower.
-// An error indication is supposed to be sent to all users in that case.
-saveDataToCache(tile, data, size);
-LOG_TRC("Saved cache tile: " << cacheFileName(tile) << " of size " << size 
<< " bytes");
+// Ignore if we can't save the tile, things will work anyway, but 
slower.
+// An error indication is supposed to be sent to all users in that 
case.
+saveDataToCache(tile, data, size);
+LOG_TRC("Saved cache tile: " << cacheFileName(tile) << " of size " << 
size << " bytes");
+}
+else
+LOG_TRC("Zero sized cache tile: " << cacheFileName(tile));
 
 // Notify subscribers, if any.
 std::shared_ptr tileBeingRendered = 
findTileBeingRendered(tile);
 if (tileBeingRendered)
 {
 const size_t subscriberCount = 
tileBeingRendered->getSubscribers().size();
-if (subscriberCount > 0)
+if (size > 0 && subscriberCount > 0)
 {
 std::string response = tile.serialize("tile:");
 LOG_DBG("Sending tile message to " << subscriberCount << " 
subscribers: " << response);
@@ -229,10 +234,9 @@ void TileCache::saveTileAndNotify(const TileDesc& tile, 
const char *data, const
 }
 }
 }
-else
-{
+else if (subscriberCount == 0)
 LOG_DBG("No subscribers for: " << cacheFileName(tile));
-}
+// else zero sized
 
 // Remove subscriptions.
 if (tileBeingRendered->getVersion() <= tile.getVersion())
@@ -243,9 +247,7 @@ void TileCache::saveTileAndNotify(const TileDesc& tile, 
const char *data, const
 }
 }
 else
-{
 LOG_DBG("No subscribers for: " << cacheFileName(tile));
-}
 }
 
 bool TileCache::getTextStream(StreamType 

[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2' - kit/Kit.cpp

2020-07-29 Thread Michael Meeks (via logerrit)
 kit/Kit.cpp |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

New commits:
commit 2d39e461200eae060e0bb7220d21972dd8076ea6
Author: Michael Meeks 
AuthorDate: Thu Jul 16 19:10:05 2020 +0100
Commit: Andras Timar 
CommitDate: Wed Jul 29 10:18:28 2020 +0200

Process any pending tileQueue items first.

Change-Id: I078bc1f52ba7647ca1715ea3222d695936dd657f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98928
Tested-by: Jenkins
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 
(cherry picked from commit 0084c3b275bbbad7f3ee2d36f86afc10fbc5400c)
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/98956
Tested-by: Andras Timar 
Reviewed-by: Andras Timar 

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 4d20d27b4..09b003efc 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1928,11 +1928,16 @@ private:
 }
 
 public:
+bool hasQueueItems() const
+{
+return _tileQueue && !_tileQueue->isEmpty();
+}
+
 void drainQueue(const std::chrono::steady_clock::time_point &/*now*/)
 {
 try
 {
-while (!_tileQueue->isEmpty())
+while (hasQueueItems())
 {
 if (_stop || SigUtil::getTerminationFlag())
 {
@@ -2201,7 +2206,10 @@ public:
 _pollEnd = std::chrono::steady_clock::now() + 
std::chrono::microseconds(timeoutMicroS);
 do
 {
-if (poll(timeoutMicroS) <= 0)
+int realTimeout = timeoutMicroS;
+if (_document && _document->hasQueueItems())
+realTimeout = 0;
+if (poll(realTimeout) <= 0)
 break;
 
 const auto now = std::chrono::steady_clock::now();
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits