Skip to content

Fix Windows compatibility for Math Animator renderer#256

Merged
pancacake merged 2 commits intoHKUDS:devfrom
kevinmw:fix/windows-manim-renderer
Apr 8, 2026
Merged

Fix Windows compatibility for Math Animator renderer#256
pancacake merged 2 commits intoHKUDS:devfrom
kevinmw:fix/windows-manim-renderer

Conversation

@kevinmw
Copy link
Copy Markdown

@kevinmw kevinmw commented Apr 7, 2026

Problem

Math Animator failed silently on Windows with no error messages. The renderer would reach "Launching Manim scene" and immediately exit with empty error content.

Root cause: asyncio.create_subprocess_exec is incompatible with Windows SelectorEventLoop (uvicorn's default), causing silent subprocess creation failures.

Solution

1. Fix subprocess execution (renderer.py)

  • Replace asyncio.create_subprocess_exec with subprocess.run + asyncio.to_thread
  • Works regardless of event loop type
  • Properly captures stdout/stderr for debugging

2. Add Manim v0.20.1 compatibility constraints (prompts)

  • Prohibit MarkupText - Requires LaTeX compilation
  • Prohibit stroke_dash_pattern - Removed in v0.20.1
  • Prohibit save_state() - Not supported in MovingCameraScene
  • Applied to both English and Chinese prompts

3. Fix i18n hydration warning (ChatComposer.tsx)

  • Add suppressHydrationWarning to textarea placeholder
  • Resolves SSR/CSR language mismatch warning

Testing

Before

✗ CLI: Silent failure after "Launching Manim scene"
✗ Web: Same silent failure
- No error messages, no video output

After

✓ CLI: Pythagorean theorem animation (660KB, 30s)
✓ Web: Cone cross-section animation
✓ Auto-retry working (Error → LLM repair → Success)

Screenshots

Successfully generated on Windows:

  • CLI mode with 中文 input
  • Web mode with real-time progress
  • Automatic code repair on first render error

Impact

  • Windows users: Can now use Math Animator
  • No breaking changes: All fixes are backward compatible
  • Better debugging: stdout/stderr now visible in logs

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

This PR fixes multiple Windows compatibility issues that prevented
the Math Animator from generating videos on Windows systems.

### Changes

1. **renderer.py**: Fix subprocess execution on Windows
   - Replace `asyncio.create_subprocess_exec` with `subprocess.run` + `asyncio.to_thread`
   - The original approach silently fails on Windows when uvicorn uses SelectorEventLoop (default)
   - New approach works regardless of event loop type

2. **code_generator_agent.yaml (en/zh)**: Add Manim v0.20.1 compatibility constraints
   - Prohibit `MarkupText` (requires LaTeX)
   - Prohibit `stroke_dash_pattern` parameter (not supported in v0.20.1)
   - Prohibit `save_state()` method (not supported in MovingCameraScene)
   - Applied to both `generate_system` and `retry_system` sections

3. **ChatComposer.tsx**: Suppress hydration warning for i18n placeholder
   - Add `suppressHydrationWarning` to textarea
   - Resolves SSR/CSR text mismatch warning for language-specific placeholders

### Testing

- ✅ CLI mode: Successfully generated Pythagorean theorem animation (660KB)
- ✅ Web mode: Successfully generated cone cross-section animation
- ✅ Auto-retry: First attempt error → LLM repair → second attempt success

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@kevinmw kevinmw force-pushed the fix/windows-manim-renderer branch from e872a90 to 7b55f11 Compare April 7, 2026 14:36
…back

Instead of replacing asyncio.create_subprocess_exec with subprocess.run
(which loses real-time streaming and cancellation), fix the root cause:
set WindowsProactorEventLoopPolicy before uvicorn starts so that
create_subprocess_exec works correctly on Windows.

This preserves the original async streaming renderer while fixing
Windows compatibility at the event loop level.

Made-with: Cursor
@pancacake pancacake changed the base branch from main to dev April 8, 2026 04:08
@pancacake pancacake merged commit a1991a0 into HKUDS:dev Apr 8, 2026
@pancacake
Copy link
Copy Markdown
Collaborator

Thanks for your contribution!

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.

2 participants