Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix(preview): no background fringe around the card's rounded corners

EtienneLescot2e6ee13d77d5
diff --git a/src/components/ai-edition/NewEditorShell.module.css b/src/components/ai-edition/NewEditorShell.module.css
index f1732d53d..ae3871c5f 100644
--- a/src/components/ai-edition/NewEditorShell.module.css
+++ b/src/components/ai-edition/NewEditorShell.module.css
@@ -362,6 +362,16 @@
display: grid;
place-items: center;
}
+/* Once the native canvas has painted, it covers the whole card, and anything painted UNDER the
+ same rounded clip leaks through its anti-aliased edge: the wallpaper placeholder and the inset
+ hairline showed as a fringe of background around each corner. So the card keeps only what lies
+ outside it, its drop shadow. `!important` because the placeholder wallpaper is an inline style. */
+.previewFrame:has(> canvas[data-painted]) {
+ background: none !important;
+ box-shadow:
+ 0 40px 90px -30px rgba(0, 0, 0, 0.75),
+ 0 12px 28px -12px rgba(0, 0, 0, 0.5);
+}
.videoStage {
position: relative;
display: grid;
diff --git a/src/native/hooks/useNativeCompositorView.test.ts b/src/native/hooks/useNativeCompositorView.test.ts
index f3bf74ad0..4107457c5 100644
--- a/src/native/hooks/useNativeCompositorView.test.ts
+++ b/src/native/hooks/useNativeCompositorView.test.ts
@@ -50,7 +50,10 @@ globalThis.ResizeObserver = class {
/** A canvas with a stubbed 2D context — jsdom has none, and the pull loop bails without it. */
function stubCanvasRef(): RefObject<HTMLCanvasElement> {
const canvas = document.createElement("canvas");
- canvas.getContext = vi.fn(() => ({})) as unknown as HTMLCanvasElement["getContext"];
+ canvas.getContext = vi.fn(() => ({
+ drawImage: vi.fn(),
+ putImageData: vi.fn(),
+ })) as unknown as HTMLCanvasElement["getContext"];
return { current: canvas };
}
@@ -100,6 +103,42 @@ describe("useNativeCompositorView", () => {
await waitFor(() => expect(mocks.readCompositorFrame).toHaveBeenCalled());
expect(result.current.error).toBeNull();
+ // No frame yet: the card keeps its placeholder background.
+ expect(ref.current?.dataset.painted).toBeUndefined();
+ });
+
+ // The preview card paints a placeholder wallpaper until the canvas has pixels; left under
+ // the same rounded clip afterwards, it showed through the anti-aliased corners. The canvas
+ // says when it has painted, and the card's CSS drops the placeholder then.
+ it("marks the canvas painted once a frame lands", async () => {
+ vi.stubGlobal(
+ "ImageData",
+ class {
+ constructor(
+ public data: Uint8ClampedArray,
+ public width: number,
+ public height: number,
+ ) {}
+ },
+ );
+ vi.stubGlobal(
+ "createImageBitmap",
+ vi.fn(async () => ({ close: vi.fn() })),
+ );
+ try {
+ mocks.createCompositorView.mockResolvedValue({ id: 1 });
+ mocks.readCompositorFrame.mockResolvedValue({
+ gen: 1,
+ width: 2,
+ height: 1,
+ data: new Uint8Array(8),
+ });
+ const ref = stubCanvasRef();
+ renderHook(() => useNativeCompositorView(ref, { sources: { screenPath: "rec.mp4" } }));
+ await waitFor(() => expect(ref.current?.dataset.painted).toBe("true"));
+ } finally {
+ vi.unstubAllGlobals();
+ }
});
it("stays quiet without an Electron bridge — no view id, so nothing is ever polled", async () => {
diff --git a/src/native/hooks/useNativeCompositorView.ts b/src/native/hooks/useNativeCompositorView.ts
index b26c9ed41..ac7e556cb 100644
--- a/src/native/hooks/useNativeCompositorView.ts
+++ b/src/native/hooks/useNativeCompositorView.ts
@@ -244,6 +244,10 @@ export function useNativeCompositorView(
// Advance only after a successful, validated frame — so a dropped/
// malformed packet is retried rather than silently skipped.
lastGen = gen;
+ // From here the canvas is the card's only pixels: the card drops its
+ // placeholder background (see `.previewFrame`), which would otherwise show
+ // through the anti-aliased rounded clip as a fringe around each corner.
+ canvas.dataset.painted = "true";
// Sonde de fluidité : signale qu'une frame a réellement été livrée, pour
// que les intervalles rAF soient rangés dans l'état « preview active »
// plutôt que moyennés avec des périodes de repos.