Animate GIFs in the presentation window#55
Merged
Conversation
Adds GifAnimationManager (src/renderer/src/lib/gif.ts), a per-canvas manager that decodes GIF data URLs via gifuct-js after the first paint and ticks frames through a scratch-canvas compositor so transparent patches do not erase prior pixels. The editor canvas, GIF backgrounds, and storage stay unchanged. Guardrails: 25 MB encoded size cap, 4096 px logical-dimension cap, 300-frame cap, 2 s post-hoc decode wallclock cap, 64 MB per-canvas memory budget with token-based reservation and reconcile-on-actual. Decode is gated by document.visibilityState; reset()/dispose() cancel schedulers, timers, and refund accounting. Presentation.svelte instantiates one manager next to presentationCanvas, calls reset() at the top of renderSlide(), registers each GIF image after its static frame loads, and start()s playback after image loads settle (including for one-GIF slides). Disposal runs before canvas disposal. The no-slide branch now also clears canvas state and resets the manager so stale visuals/timers do not survive a wipe. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Fixes two issues surfaced during QA: 1. The properties panel background preview uses a native <img> tag, so browsers animated the GIF in the editor sidebar even though the canvas GIF stays static. PropertiesPanel.svelte now detects GIF backgrounds and shows the decoded first frame instead, matching the editor canvas. 2. Adds getGifFirstFrameDataUrl(src) in lib/gif.ts — a small async helper that parses the GIF, renders frame 0 through a scratch canvas onto a composite, and returns a PNG data URL. Results are cached by source so repeated previews don't re-decode. Falls back to the original URL on any error so the preview never goes blank. This is a small editor-side affordance; presentation playback is unchanged. (The plan kept App.svelte and presentation behavior fixed; this only touches PropertiesPanel preview rendering and the gif module.) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GifAnimationManager(src/renderer/src/lib/gif.ts) — a per-canvas manager that decodes GIF data URLs viagifuct-jsafter the first paint and ticks frames through a scratch-canvas compositor so transparent patches do not erase prior pixels.Presentation.svelte: one instance alongsidepresentationCanvas,reset()at the top ofrenderSlide, fire-and-forgetregister()after each static image load,start()after image loads settle (works for one-GIF slides too),dispose()before canvas disposal, and full canvas/state cleanup in the no-slide branch.App.svelteare unchanged.Guardrails (warn-once, fall back to static)
reset()document.visibilityStatepauses scheduling; resumes when visibleTest Plan
npm run typecheck— cleannpm run lint— cleannpm test— 131/131 pass (31 new intests/renderer/lib/gif.test.ts)🤖 Generated with Claude Code