Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(editor): capture canvas frame when opening crop dialog

Richie McIlroy8ac0875dc49d
diff --git a/apps/desktop/src/routes/editor/Player.tsx b/apps/desktop/src/routes/editor/Player.tsx
index 60e622dfe..a35b07b86 100644
--- a/apps/desktop/src/routes/editor/Player.tsx
+++ b/apps/desktop/src/routes/editor/Player.tsx
@@ -50,6 +50,7 @@ export function PlayerContent() {
setEditorState,
zoomOutLimit,
setProject,
+ canvasControls,
previewResolutionBase,
previewQuality,
setPreviewQuality,
@@ -158,6 +159,8 @@ export function PlayerContent() {
const cropDialogHandler = async () => {
const startedAt = performance.now();
const display = editorInstance.recordings.segments[0].display;
+ const controls = canvasControls();
+ let previewUrl: string | null = null;
logCropProfile("click", {
recordingDurationSec: Math.round(editorInstance.recordingDuration),
playbackTimeSec: Number(editorState.playbackTime.toFixed(3)),
@@ -165,6 +168,20 @@ export function PlayerContent() {
displayHeight: display.height,
wasPlaying: editorState.playing,
});
+ if (controls?.hasRenderedFrame()) {
+ try {
+ const previewFrame = await controls.captureFrame();
+ if (previewFrame) {
+ previewUrl = URL.createObjectURL(previewFrame);
+ }
+ } catch (error) {
+ console.warn("Preview frame capture failed:", error);
+ }
+ }
+ logCropProfile("preview-frame-captured", {
+ elapsedMs: Number((performance.now() - startedAt).toFixed(2)),
+ available: previewUrl !== null,
+ });
setDialog({
open: true,
type: "crop",
@@ -177,6 +194,7 @@ export function PlayerContent() {
y: display.height,
}),
},
+ previewUrl,
});
logCropProfile("dialog-opened", {
elapsedMs: Number((performance.now() - startedAt).toFixed(2)),