Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Limit retries in advanceReadIndexCAS loop

Richie McIlroyba81a7656dbb
diff --git a/apps/desktop/src/utils/shared-frame-buffer.ts b/apps/desktop/src/utils/shared-frame-buffer.ts
index 275e76c42..24a463724 100644
--- a/apps/desktop/src/utils/shared-frame-buffer.ts
+++ b/apps/desktop/src/utils/shared-frame-buffer.ts
@@ -252,8 +252,10 @@ function advanceReadIndexCAS(
readIdx: number,
nextIdx: number,
): void {
+ const MAX_ADVANCE_RETRIES = 16;
let expectedIdx = readIdx;
- while (true) {
+
+ for (let attempt = 0; attempt < MAX_ADVANCE_RETRIES; attempt++) {
const exchanged = Atomics.compareExchange(
controlView,
CONTROL_READ_INDEX,