[Libreoffice-commits] online.git: 2 commits - wsd/ClientSession.cpp wsd/ClientSession.hpp wsd/DocumentBroker.cpp wsd/TestStubs.cpp wsd/TileCache.cpp wsd/TileCache.hpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Aug 1 16:33:42 UTC 2018
wsd/ClientSession.cpp | 32 ++++++++++++++++++++++++++++++++
wsd/ClientSession.hpp | 15 +++++++++------
wsd/DocumentBroker.cpp | 19 +++++++++++--------
wsd/TestStubs.cpp | 6 ++++++
wsd/TileCache.cpp | 17 +++++++++++++----
wsd/TileCache.hpp | 1 +
6 files changed, 72 insertions(+), 18 deletions(-)
New commits:
commit 165e5b4e1cf4c62e4667c6ad118479062e49b1d2
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Jul 31 15:42:58 2018 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Jul 31 17:19:12 2018 +0200
Use a bigger number as a tiles-on-fly limit
So scrolling can be more smooth.
Change-Id: I7b029c0ccc2de6883db54493a9188ae54a346a1d
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index be51bb1c5..a0bb71902 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -41,7 +41,7 @@
#include <sys/types.h>
#include <sys/wait.h>
-#define TILES_ON_FLY_MIN_UPPER_LIMIT 10u
+#define TILES_ON_FLY_MIN_UPPER_LIMIT 10.0f
using namespace LOOLProtocol;
@@ -1368,13 +1368,13 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
std::unique_lock<std::mutex> lock(_mutex);
// How many tiles we have on the visible area, set the upper limit accordingly
- const unsigned tilesFitOnWidth = static_cast<unsigned>(std::ceil(static_cast<float>(session->getVisibleArea().getWidth()) /
- static_cast<float>(session->getTileWidthInTwips())));
- const unsigned tilesFitOnHeight = static_cast<unsigned>(std::ceil(static_cast<float>(session->getVisibleArea().getHeight()) /
- static_cast<float>(session->getTileHeightInTwips())));
- const unsigned tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
+ const float tilesFitOnWidth = static_cast<float>(session->getVisibleArea().getWidth()) /
+ static_cast<float>(session->getTileWidthInTwips());
+ const float tilesFitOnHeight = static_cast<float>(session->getVisibleArea().getHeight()) /
+ static_cast<float>(session->getTileHeightInTwips());
+ const float tilesInVisArea = tilesFitOnWidth * tilesFitOnHeight;
- const unsigned tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, tilesInVisArea);
+ const float tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, tilesInVisArea * 1.5f);
// Update client's tilesBeingRendered list
session->removeOutdatedTileSubscriptions();
commit 8d95ca716568272f6246d959aeda5109adefa5a3
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Tue Jul 31 14:47:27 2018 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Tue Jul 31 15:44:15 2018 +0200
Make client tilesBeingRendered tracking more robust
Store the tile cache names and drop outdated tiles
times to times, so we can avoid tile rendering / sending to
stuck.
Change-Id: Ibff001307c7c660cbc57ab20c29c430e0090444d
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index 886a3dcec..6f8e26aed 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -1256,6 +1256,38 @@ void ClientSession::traceTileBySend(const TileDesc& tile)
addTileOnFly(tile);
}
+void ClientSession::traceSubscribeToTile(const std::string& cacheName)
+{
+ _tilesBeingRendered.insert(cacheName);
+}
+
+void ClientSession::traceUnSubscribeToTile(const std::string& cacheName)
+{
+ _tilesBeingRendered.erase(cacheName);
+}
+
+void ClientSession::removeOutdatedTileSubscriptions()
+{
+ const std::shared_ptr<DocumentBroker> docBroker = getDocumentBroker();
+ if(!docBroker)
+ return;
+
+ auto iterator = _tilesBeingRendered.begin();
+ while(iterator != _tilesBeingRendered.end())
+ {
+ double elapsedTime = docBroker->tileCache().getTileBeingRenderedElapsedTimeMs(*iterator);
+ if(elapsedTime < 0.0 && elapsedTime > 5000.0)
+ _tilesBeingRendered.erase(iterator);
+ else
+ ++iterator;
+ }
+}
+
+void ClientSession::clearTileSubscription()
+{
+ _tilesBeingRendered.clear();
+}
+
std::string ClientSession::generateTileID(const TileDesc& tile)
{
std::ostringstream tileID;
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 8d434f44a..29618a6cd 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -20,6 +20,7 @@
#include <boost/optional.hpp>
#include <list>
#include <map>
+#include <unordered_set>
class DocumentBroker;
@@ -140,11 +141,13 @@ public:
/// Call this method anytime when a new tile is sent to the client
void traceTileBySend(const TileDesc& tile);
- void traceSubscribe() { ++_tilesBeingRendered; }
- void traceUnSubscribe() { --_tilesBeingRendered; }
- void clearSubscription() { _tilesBeingRendered = 0; }
+ /// Trask tiles what we a subscription to
+ void traceSubscribeToTile(const std::string& tileCacheName);
+ void traceUnSubscribeToTile(const std::string& tileCacheName);
+ void removeOutdatedTileSubscriptions();
+ void clearTileSubscription();
- int getTilesBeingRendered() const {return _tilesBeingRendered;}
+ size_t getTilesBeingRenderedCount() const {return _tilesBeingRendered.size();}
private:
/// SocketHandler: disconnection event.
@@ -244,9 +247,9 @@ private:
/// TileID's of the sent tiles. Push by sending and pop by tileprocessed message from the client.
std::list<std::string> _tilesOnFly;
- /// Number of tiles requested from kit, which this session is subsrcibed to
+ /// Names of tiles requested from kit, which this session is subsrcibed to
/// Track only non-thumbnail tiles (getId() == -1)
- int _tilesBeingRendered;
+ std::unordered_set<std::string> _tilesBeingRendered;
/// Requested tiles are stored in this list, before we can send them to the client
boost::optional<std::list<TileDesc>> _requestedTiles;
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index e6ead209a..be51bb1c5 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -1376,13 +1376,16 @@ void DocumentBroker::sendRequestedTiles(const std::shared_ptr<ClientSession>& se
const unsigned tilesOnFlyUpperLimit = std::max(TILES_ON_FLY_MIN_UPPER_LIMIT, tilesInVisArea);
+ // Update client's tilesBeingRendered list
+ session->removeOutdatedTileSubscriptions();
+
// 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<std::list<TileDesc>>& requestedTiles = session->getRequestedTiles();
if(requestedTiles != boost::none && !requestedTiles.get().empty())
{
std::vector<TileDesc> tilesNeedsRendering;
- while(session->getTilesOnFlyCount() + session->getTilesBeingRendered() < tilesOnFlyUpperLimit
+ while(session->getTilesOnFlyCount() + session->getTilesBeingRenderedCount() < tilesOnFlyUpperLimit
&& !requestedTiles.get().empty())
{
TileDesc& tile = *(requestedTiles.get().begin());
diff --git a/wsd/TestStubs.cpp b/wsd/TestStubs.cpp
index 0a1f7524b..038c2f9de 100644
--- a/wsd/TestStubs.cpp
+++ b/wsd/TestStubs.cpp
@@ -22,4 +22,10 @@ void DocumentBroker::assertCorrectThread() const {}
void ClientSession::traceTileBySend(const TileDesc& /*tile*/) {}
+void ClientSession::traceSubscribeToTile(const std::string& /*tileCacheName*/) {};
+
+void ClientSession::traceUnSubscribeToTile(const std::string& /*tileCacheName*/) {};
+
+void ClientSession::clearTileSubscription() {};
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp
index cb9e2a354..e2bf45c84 100644
--- a/wsd/TileCache.cpp
+++ b/wsd/TileCache.cpp
@@ -130,12 +130,21 @@ void TileCache::forgetTileBeingRendered(std::shared_ptr<TileCache::TileBeingRend
{
std::shared_ptr<ClientSession> session = subscriber.lock();
if(session && tile.getId() == -1)
- session->traceUnSubscribe();
+ session->traceUnSubscribeToTile(tileBeingRendered->getCacheName());
}
_tilesBeingRendered.erase(tileBeingRendered->getCacheName());
}
+double TileCache::getTileBeingRenderedElapsedTimeMs(const std::string& tileCacheName) const
+{
+ auto iterator = _tilesBeingRendered.find(tileCacheName);
+ if(iterator == _tilesBeingRendered.end())
+ return -1.0; // Negativ value means that we did not find tileBeingRendered object
+
+ return iterator->second->getElapsedTimeMs();
+}
+
std::unique_ptr<std::fstream> TileCache::lookupTile(const TileDesc& tile)
{
const std::string fileName = _cacheDir + "/" + cacheFileName(tile);
@@ -491,7 +500,7 @@ void TileCache::subscribeToTileRendering(const TileDesc& tile, const std::shared
tileBeingRendered->_subscribers.size() << " subscribers already.");
tileBeingRendered->_subscribers.push_back(subscriber);
if(tile.getId() == -1)
- subscriber->traceSubscribe();
+ subscriber->traceSubscribeToTile(tileBeingRendered->getCacheName());
const auto duration = (std::chrono::steady_clock::now() - tileBeingRendered->getStartTime());
if (std::chrono::duration_cast<std::chrono::milliseconds>(duration).count() > COMMAND_TIMEOUT_MS)
@@ -512,7 +521,7 @@ void TileCache::subscribeToTileRendering(const TileDesc& tile, const std::shared
tileBeingRendered = std::make_shared<TileBeingRendered>(cachedName, tile);
tileBeingRendered->_subscribers.push_back(subscriber);
if(tile.getId() == -1)
- subscriber->traceSubscribe();
+ subscriber->traceSubscribeToTile(tileBeingRendered->getCacheName());
_tilesBeingRendered[cachedName] = tileBeingRendered;
}
}
@@ -560,7 +569,7 @@ std::string TileCache::cancelTiles(const std::shared_ptr<ClientSession> &subscri
}
if(sub)
- sub->clearSubscription();
+ sub->clearTileSubscription();
const std::string canceltiles = oss.str();
return canceltiles.empty() ? canceltiles : "canceltiles " + canceltiles;
}
diff --git a/wsd/TileCache.hpp b/wsd/TileCache.hpp
index 63adad265..e4573b465 100644
--- a/wsd/TileCache.hpp
+++ b/wsd/TileCache.hpp
@@ -80,6 +80,7 @@ public:
void saveLastModified(const Poco::Timestamp& timestamp);
void forgetTileBeingRendered(std::shared_ptr<TileCache::TileBeingRendered> tileBeingRendered, const TileDesc& tile);
+ double getTileBeingRenderedElapsedTimeMs(const std::string& tileCacheName) const;
void setThreadOwner(const std::thread::id &id) { _owner = id; }
void assertCorrectThread();
More information about the Libreoffice-commits
mailing list