Improve connection resiliency

Remove some spurious locking around NativeScript/Java interfaces that
were added while debugging something that turned out to be unrelated.
Don't send messages to the left lens while a heartbeat is pending on the
right lens.
This commit is contained in:
James Babcock committed 2026-05-02 00:48:08 -07:00
1 parent bcc30545ad
commit 05775a927c
3 files changed
+46 -154

No files matched your search

+11 -26
View File
@@ -177,15 +177,6 @@ export class FaceclawCommunicatorBridge {
return result;
}
private withNativeBridgeLock<T>(operation: string, callback: () => T): T {
this.communicator.acquireNativeBridgeLock(operation);
try {
return callback();
} finally {
this.communicator.releaseNativeBridgeLock(operation);
}
}
onLog(listener: (line: string) => void): () => void {
this.logListeners.add(listener);
return () => this.logListeners.delete(listener);
@@ -250,25 +241,21 @@ export class FaceclawCommunicatorBridge {
}
const tileSnapshots = tileBmps.map((tile) => new Uint8Array(tile));
await this.enqueueJavaCall(() => {
this.withNativeBridgeLock("submitDashboardImage4 bridge arrays", () => {
this.communicator.submitDashboardImage4(
toJavaByteArray(tileSnapshots[0]!),
toJavaByteArray(tileSnapshots[1]!),
toJavaByteArray(tileSnapshots[2]!),
toJavaByteArray(tileSnapshots[3]!),
fingerprint,
forceTiledCommit,
Math.round(nonNegativeNumber(paintMs)),
);
});
this.communicator.submitDashboardImage4(
toJavaByteArray(tileSnapshots[0]!),
toJavaByteArray(tileSnapshots[1]!),
toJavaByteArray(tileSnapshots[2]!),
toJavaByteArray(tileSnapshots[3]!),
fingerprint,
forceTiledCommit,
Math.round(nonNegativeNumber(paintMs)),
);
});
}
async createPreviewBitmap(colors: number[], width: number, height: number): Promise<any> {
return this.enqueueJavaCall(() =>
this.withNativeBridgeLock("createPreviewBitmap bridge", () =>
this.communicator.createPreviewBitmap(colors, width, height),
),
this.communicator.createPreviewBitmap(colors, width, height),
);
}
@@ -278,9 +265,7 @@ export class FaceclawCommunicatorBridge {
height: number,
): Promise<any> {
return this.enqueueJavaCall(() =>
this.withNativeBridgeLock("createPreviewBitmap bridge colors", () =>
this.communicator.createPreviewBitmap(createColors(), width, height),
),
this.communicator.createPreviewBitmap(createColors(), width, height),
);
}