Skip to content

Commit 22363c4

Browse files
author
Chris Lord
committed
Make draw pausing around dehydration simpler and more reliable
Instead of nesting pause/resume on tile dehydration, just pause once when we go to dehydrate a visible tile and resume when all tiles that don't require fetching have no pending updates. Signed-off-by: Chris Lord <chris.lord@collabora.com> Change-Id: I9b3391556884a19678a3885f804577ed8ee8c88a
1 parent d11671a commit 22363c4

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

browser/src/app/TilesMiddleware.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ class TileManager {
242242
// The tile expansion ratio that the visible tile area will be expanded towards when
243243
// updating during scrolling
244244
private static directionalTileExpansion: number = 2;
245+
private static pausedForDehydration: boolean = false;
245246

246247
//private static _debugTime: any = {}; Reserved for future.
247248

@@ -475,6 +476,26 @@ class TileManager {
475476
}
476477
}
477478

479+
if (this.pausedForDehydration) {
480+
// Check if all current tiles are accounted for and resume drawing if so.
481+
let shouldUnpause = true;
482+
for (const key in this.tiles) {
483+
const tile = this.tiles[key];
484+
if (
485+
tile.distanceFromView === 0 &&
486+
!tile.needsFetch() &&
487+
tile.hasPendingUpdate()
488+
) {
489+
shouldUnpause = false;
490+
break;
491+
}
492+
}
493+
if (shouldUnpause) {
494+
app.sectionContainer.resumeDrawing();
495+
this.pausedForDehydration = false;
496+
}
497+
}
498+
478499
this.garbageCollect();
479500
}
480501

@@ -1489,12 +1510,11 @@ class TileManager {
14891510
}
14901511

14911512
// If we dehydrated a visible tile, wait for it to be ready before drawing
1492-
if (dehydratedVisible) {
1513+
if (dehydratedVisible && !this.pausedForDehydration) {
14931514
app.sectionContainer.pauseDrawing();
1494-
this.endTransaction(() => {
1495-
app.sectionContainer.resumeDrawing();
1496-
});
1497-
} else this.endTransaction(null);
1515+
this.pausedForDehydration = true;
1516+
}
1517+
this.endTransaction(null);
14981518

14991519
return queue;
15001520
}

0 commit comments

Comments
 (0)