Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop): reveal transparent editor without throttled rAF

Richie McIlroya2ce530d4204
diff --git a/apps/desktop/src/routes/editor/index.tsx b/apps/desktop/src/routes/editor/index.tsx
index 05dadaebc..b4cabd2d1 100644
--- a/apps/desktop/src/routes/editor/index.tsx
+++ b/apps/desktop/src/routes/editor/index.tsx
@@ -10,10 +10,13 @@ import { EditorSkeleton } from "./editor-skeleton";
export default function () {
const generalSettings = generalSettingsStore.createQuery();
- // The editor window is built hidden (AUTO_SHOW_WINDOW=false) so we can reveal
- // it only after the theme + transparency are applied and the first frame has
- // painted. Showing earlier (the old behaviour) exposed the placeholder
- // background and then the themed background, producing a visible flash.
+ // The window is normally revealed by Rust as soon as it's built and
+ // positioned (the native background color is themed, so there's no flash).
+ // This reveal path only matters when window transparency is enabled — Rust
+ // keeps the window hidden so we can apply the HudWindow effects before it
+ // becomes visible. Note: requestAnimationFrame must NOT be used to schedule
+ // the reveal — hidden webviews throttle/suspend rAF, which silently pushed
+ // every editor open onto the slow fallback timeout.
let revealed = false;
const reveal = () => {
if (revealed) return;
@@ -25,19 +28,18 @@ export default function () {
createEffect(() => {
const transparent = generalSettings.data?.windowTransparency ?? false;
- commands.setWindowTransparent(transparent);
- getCurrentWindow().setEffects({
- effects: transparent ? [Effect.HudWindow] : [],
- });
- // Once settings have loaded (theme + transparency are now applied), reveal
- // on the next frame so the styled background paints before the window is
- // visible.
- if (generalSettings.data) requestAnimationFrame(reveal);
+ const applied = Promise.allSettled([
+ commands.setWindowTransparent(transparent),
+ getCurrentWindow().setEffects({
+ effects: transparent ? [Effect.HudWindow] : [],
+ }),
+ ]);
+ if (generalSettings.data) void applied.then(reveal);
});
// Hard fallback: never leave the window hidden if settings fail to load.
onMount(() => {
- setTimeout(reveal, 1000);
+ setTimeout(reveal, 250);
});
return (