Skip to content

Commit d11671a

Browse files
author
Chris Lord
committed
Skip decompressing keyframes that become not-current
If a subsequent transaction makes a pending tile dehydration unnecessary, skip it to catch up more quickly. Signed-off-by: Chris Lord <chris.lord@collabora.com> Change-Id: I3cd76e414536d2a762291ed857eee0dcdd3307ff
1 parent ba4eb35 commit d11671a

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

browser/src/app/TilesMiddleware.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,9 @@ class TileManager {
512512
message: message,
513513
deltas: this.pendingDeltas,
514514
tileSize: this.tileSize,
515+
current: Object.keys(this.tiles).filter(
516+
(k) => this.tiles[k].distanceFromView === 0,
517+
),
515518
},
516519
this.pendingDeltas.map((x: any) => x.rawDelta.buffer),
517520
);
@@ -2142,20 +2145,28 @@ class TileManager {
21422145
}
21432146

21442147
let keyframeImage = null;
2145-
if (x.isKeyframe)
2146-
keyframeImage = new ImageData(
2147-
x.keyframeBuffer,
2148-
e.data.tileSize,
2149-
e.data.tileSize,
2148+
if (x.isKeyframe) {
2149+
if (x.keyframeBuffer)
2150+
keyframeImage = new ImageData(
2151+
x.keyframeBuffer,
2152+
e.data.tileSize,
2153+
e.data.tileSize,
2154+
);
2155+
else {
2156+
tile.imgDataCache = null;
2157+
tile.rawDeltas = x.rawDelta;
2158+
}
2159+
}
2160+
2161+
if (!x.isKeyframe || keyframeImage)
2162+
this.applyDelta(
2163+
tile,
2164+
x.rawDelta,
2165+
x.deltas,
2166+
x.keyframeDeltaSize,
2167+
keyframeImage,
2168+
x.wireMessage,
21502169
);
2151-
this.applyDelta(
2152-
tile,
2153-
x.rawDelta,
2154-
x.deltas,
2155-
x.keyframeDeltaSize,
2156-
keyframeImage,
2157-
x.wireMessage,
2158-
);
21592170

21602171
this.createTileBitmap(tile, x, pendingDeltas, bitmaps);
21612172
}

browser/src/layer/tile/CanvasTileWorkerSrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const PROCESS_TIME = 10;
1818

1919
let transactionHandlerId = null;
2020
const transactions = [];
21+
let currentKeys = new Set();
2122

2223
function transactionCallback(start_time = null) {
2324
if (start_time === null) start_time = performance.now();
@@ -36,6 +37,9 @@ function transactionCallback(start_time = null) {
3637
transaction.decompressed.push(tile);
3738
transaction.buffers.push(tile.rawDelta.buffer);
3839

40+
// Skip keyframe tiles that are no longer current
41+
if (tile.isKeyframe && !currentKeys.has(tile.key)) continue;
42+
3943
const deltas = self.fzstd.decompress(tile.rawDelta);
4044
tile.keyframeDeltaSize = 0;
4145

@@ -104,6 +108,7 @@ if ('undefined' === typeof window) {
104108
function onMessage(e) {
105109
switch (e.data.message) {
106110
case 'endTransaction':
111+
currentKeys = new Set(e.data.current);
107112
transactions.push({
108113
data: e.data,
109114
decompressed: [],

0 commit comments

Comments
 (0)