From 7ff4c9ffcd146e0f7dc65c0e50a8a90ae4843edd Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Thu, 16 Jun 2022 14:42:40 +0100 Subject: [PATCH] delta: don't clear keyframes from the cache that have deltas coming. These will get newer wids later of course. Signed-off-by: Michael Meeks Change-Id: I906f47255854eb065d41e629508867ffa6e9f953 --- wsd/DocumentBroker.cpp | 4 +++- wsd/TileCache.cpp | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index aa704a387..5433d0c15 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -2745,7 +2745,8 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined, bool assert(!tileCombined.hasDuplicates()); - LOG_TRC("TileCombined request for " << tileCombined.serialize()); + LOG_TRC("TileCombined request for " << tileCombined.serialize() << " from " << + (forceKeyframe ? "client" : "wsd")); if (!hasTileCache()) { LOG_WRN("Combined tile request without a loaded document?"); @@ -2767,6 +2768,7 @@ void DocumentBroker::handleTileCombinedRequest(TileCombined& tileCombined, bool // case; so forget what we last sent. LOG_TRC("forcing a keyframe for tilecombined tile"); session->resetTileSeq(tile); + tile.setOldWireId(0); // forceKeyframe in the request } Tile cachedTile = _tileCache->lookupTile(tile); diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp index 09ead6a1e..a9fc3bdb6 100644 --- a/wsd/TileCache.cpp +++ b/wsd/TileCache.cpp @@ -588,6 +588,7 @@ void TileCache::ensureCacheSize() if (wids.back()._wid - wids.front()._wid > 256 * 256 * 256) { maxToRemove = wids.back()._wid; + LOG_TRC("Rare wid wrap-around detected, clear tile cache"); } else { @@ -608,9 +609,20 @@ void TileCache::ensureCacheSize() { if (it->first.getWireId() <= maxToRemove) { - LOG_TRC("cleaned out tile: " << it->first.serialize()); - _cacheSize -= itemCacheSize(it->second); - it = _cache.erase(it); + auto rit = _tilesBeingRendered.find(it->first); + if (rit != _tilesBeingRendered.end()) + { + // avoid getting a delta instead of a keyframe at the bottom. + LOG_TRC("skip cleaning tile we are waiting on: " << it->first.serialize() << + " which has " << rit->second->getSubscribers().size() << " waiting"); + ++it; + } + else + { + LOG_TRC("cleaned out tile: " << it->first.serialize()); + _cacheSize -= itemCacheSize(it->second); + it = _cache.erase(it); + } } else {