Skip to content

fix(export): keep large exports off in-memory save path#453

Merged
meiiie merged 1 commit into
mainfrom
fix/issue445-large-export-stream-save
May 8, 2026
Merged

fix(export): keep large exports off in-memory save path#453
meiiie merged 1 commit into
mainfrom
fix/issue445-large-export-stream-save

Conversation

@meiiie
Copy link
Copy Markdown
Collaborator

@meiiie meiiie commented May 8, 2026

Description

Fixes #445 by keeping MP4 export saves on the temp-file streaming/finalize path instead of silently falling back to renderer/main-process ArrayBuffer saves when the output is large or when Electron MP4 streaming fails.

Motivation

The v1.3.0 beta still had a legacy in-memory save path that could be reached after a Blob export. For outputs over Node/Electron's Buffer limit, that path can fail with the same >2 GiB class of error reported in #445.

Type

Bug fix

Related Issue(s)

Fixes #445

Changes Made

  • Added an explicit export-save policy for the in-memory fallback limit.
  • Blocked Electron MP4 saves from falling back to the legacy blob.arrayBuffer() path after temp-file streaming fails.
  • Added main-process guards so old IPC paths reject oversized ArrayBuffer saves with a clear message.
  • Added focused tests for the save policy and kept existing export stream/muxer tests green.

Scope Note

This does not change rendering, muxing quality, or native CUDA/D3D11 selection. It only hardens the final save/mux handoff so large exports stay on disk-backed paths.

Testing Guide

  1. Export a small MP4 through Lightning and confirm the save dialog still works.
  2. Export a large MP4 expected to exceed 2 GiB and confirm it completes through the temp-file path instead of throwing a Buffer/ArrayBuffer size error.
  3. If a large MP4 still fails, collect the export error and whether it failed during render, mux/finalize, or save dialog.

Validation

  • npm test -- src/lib/exporter/exportSavePolicy.test.ts electron/ipc/export/exportStream.test.ts electron/ipc/register/export.test.ts src/lib/exporter/muxer.test.ts
  • npm exec -- tsc --noEmit
  • npx biome check --formatter-enabled=false src/lib/exporter/exportSavePolicy.ts src/lib/exporter/exportSavePolicy.test.ts src/components/video-editor/VideoEditor.tsx electron/ipc/register/export.ts
  • npx vite build --config vite.config.ts
  • npm run normalize:electron-main-cjs
  • npm run smoke:electron-main-cjs

Checklist

Summary by CodeRabbit

  • New Features

    • Added file-size validation for video exports to prevent processing failures
    • Implemented intelligent fallback logic that selects the appropriate save method based on video size and format
  • Bug Fixes

    • Improved handling of large video exports by utilizing streaming-based processing instead of memory-intensive operations
    • Enhanced error messaging when exports exceed system limitations
    • Better MP4 export handling when streaming capabilities are available

@meiiie meiiie mentioned this pull request May 8, 2026
1 task
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 940c7ba3-861b-4d1c-8ce8-c29de3d89085

📥 Commits

Reviewing files that changed from the base of the PR and between 144698c and 4f89a6d.

📒 Files selected for processing (4)
  • electron/ipc/register/export.ts
  • src/components/video-editor/VideoEditor.tsx
  • src/lib/exporter/exportSavePolicy.test.ts
  • src/lib/exporter/exportSavePolicy.ts

📝 Walkthrough

Walkthrough

This PR adds size constraints for in-memory video exports by introducing a 2GB limit and conditional fallback policy. It defines size-checking utilities and applies them across IPC handlers and client-side fallback logic, with tests validating the policy behavior.

Changes

In-Memory Export Size Guards

Layer / File(s) Summary
Policy Definitions
src/lib/exporter/exportSavePolicy.ts
Introduces MAX_IN_MEMORY_EXPORT_BYTES (0x7fffffff), normalizeExportExtension(), isExportTooLargeForInMemorySave(), canUseInMemoryExportSaveFallback(), and describeBlockedInMemoryExportSave() to define export save-path eligibility based on size and streaming API availability.
IPC Handler Guards
electron/ipc/register/export.ts
Adds local size guard constant and helper; updates mux-exported-video-audio, save-exported-video, and write-exported-video-to-path handlers to reject oversized videoData early with descriptive errors before processing.
Client-Side Fallback Logic
src/components/video-editor/VideoEditor.tsx
Imports policy helpers; saveBlobExport now detects streaming API availability, catches temp-file failures, and conditionally gates in-memory fallback via policy check, throwing detailed errors when fallback is blocked.
Policy Tests
src/lib/exporter/exportSavePolicy.test.ts
Vitest suite validates extension normalization, size-limit rejection, MP4 format blocking with streaming APIs, small-export fallback allowance, and error message correctness.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • webadderallorg/Recordly#278: Modifies electron/ipc/register/export.ts to handle user path approval and path normalization in the same export handlers.
  • webadderallorg/Recordly#404: Updates the mux-exported-video-audio IPC handler to use a temp-file path instead of in-memory reads, directly affected by this PR's size guard injection.
  • webadderallorg/Recordly#284: Modifies the same mux-exported-video-audio handler path in electron/ipc/register/export.ts.

Suggested labels

Checked

Poem

🐰 Two gigs! That's quite the haul to hoard,
In memory's vault, we've set a new board!
When buffers grow large beyond our small space,
We fallback with grace—a safe, steady pace.
No crashing exports, no sizes run wild,
Your videos now save—forever beguiled! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: preventing large exports from using the in-memory save path.
Description check ✅ Passed The description is comprehensive, covering motivation, type, related issues, changes made, scope, testing guide, and validation commands, closely following the template structure.
Linked Issues check ✅ Passed The PR addresses issue #445 by implementing disk-backed temp-file paths for large exports and blocking in-memory fallback, directly solving the >2 GiB export failure reported.
Out of Scope Changes check ✅ Passed All changes are focused on export save-path routing and in-memory limit guards; no unrelated modifications to rendering, muxing, or GPU selection are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue445-large-export-stream-save

Comment @coderabbitai help to get the list of available commands and usage tips.

@meiiie meiiie marked this pull request as ready for review May 8, 2026 15:45
@meiiie meiiie merged commit ca9192a into main May 8, 2026
3 checks passed
@meiiie meiiie deleted the fix/issue445-large-export-stream-save branch May 8, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: can not export more than 2gb

1 participant