Skip to content

fix(render): cross-fade pose release instead of hard-cutting to idle - #315

Open
sanketpatel32 wants to merge 3 commits into
Code-Amadeus:mainfrom
sanketpatel32:issue-263-pose-release-transition
Open

sanketpatel32 wants to merge 3 commits into
Code-Amadeus:mainfrom
sanketpatel32:issue-263-pose-release-transition

Conversation

@sanketpatel32

Copy link
Copy Markdown
Contributor

Fixes #263

Problem

After speech ends, a posed character snaps back to standing/idle in a single frame ("角色说完话回到站立时是一个瞬间跳变"). The post-speech release path calls _playNode directly and the pose graph has no pose→idle transition edges or release clips, so setEmotion hard-cuts.

Fix (owning layer: render/web/renderer.js, SpriteRenderer.setEmotion)

When a clip change has no authored transition frames, the renderer now keeps the outgoing frame visible as an overlay sprite and dissolves it over a configurable duration instead of cutting:

  • renderPoseFadeMs query param / RENDER_POSE_FADE_MS env var, default 200 ms (clamped 0–2000; 0 restores the previous hard cut).
  • Smoothstep alpha fade on the ticker, independent of the held/idle frame loop.
  • The outgoing texture is pinned in the frame store (or display-retained for video-backed clips) for the fade window so the LRU window cannot evict it mid-fade; released on completion, replacement, or character teardown.
  • Authored transition clips still take precedence when present — this only fills the gap where no release clip exists.
  • A second clip change restarts the fade from the currently displayed frame.

Plumbing

RENDER_POSE_FADE_MS reaches every render surface: render_handler.py (desktop), wallpaper_engine_bridge.py/wallpaper_handler.py (bridge-info + URL), wallpaper/lively/index.html, and the Electron chain (main/index.ts descriptor/normalize/URL, preload/index.mts, env.d.ts, wallpaperSlice.ts). Documented in config/README.md.

Tests

  • New tests/sprite_pose_fade.test.cjs (5 contracts: dissolve+pin release, =0 hard cut, authored-transition precedence, fade replacement mid-flight, teardown pin release) + tests/test_sprite_pose_fade.py wrapper.
  • Existing VM fixtures pin poseFadeMs: 0 to keep their hard-cut assumptions explicit.
  • tests/test_wallpaper_asset_revision.py updated for the new URL contract.

Verification

  • node --test: sprite_pose_fade 5/5, sprite_texture_lifecycle 24/24, sprite_canvas_fit 4/4, sprite_frame_sampling 18/18, sprite_video_source 27/27, hybrid_lifecycle 4/4; post-speech handoff script OK.
  • pytest: test_sprite_pose_fade, test_spriteforge_post_speech_handoff, test_render_budget, test_sprite_texture_lifecycle, test_sprite_frame_sampling, test_frame_store (27 passed); test_electron_renderer_boundary + test_wallpaper_asset_revision + test_wallpaper_bridge_portability (16 passed, 1 skipped).
  • Not run: Electron tsc/vite build (deps not installed locally); node --check passes on all touched JS.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

When a clip change has no authored transition frames — the common case
for the post-speech pose release back to standing, whose graph edges and
release clips do not exist — the renderer now keeps the outgoing frame
on screen as an overlay sprite and dissolves it over RENDER_POSE_FADE_MS
(default 200 ms) instead of jumping in a single frame.

The outgoing texture is pinned in the frame store (or display-retained
for video-backed clips) for the fade window so the texture window cannot
evict it mid-fade, and the pin is released when the fade completes, is
replaced by a newer clip change, or the character deactivates. Authored
transition clips still take precedence, and renderPoseFadeMs=0 restores
the previous hard cut.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Signed-off-by: Sanket Patel <sanpatel323@gmail.com>
@sanketpatel32
sanketpatel32 force-pushed the issue-263-pose-release-transition branch from dee9f7d to 927f34b Compare November 22, 2026 23:54

@Lucas1479 Lucas1479 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @sanketpatel32 for picking up #263. The overlay approach is clean, and pinning the outgoing texture so the frame store can't evict it mid-fade is the right detail.

A few changes are needed:

  1. CI blocker. RENDER_POSE_FADE_MS is declared by hand in config/settings.py, so tests/test_config_catalog.py::test_no_new_or_migrated_handwritten_config_declarations fails with "declare RENDER_POSE_FADE_MS in the catalog". Please declare it in the config catalog.

  2. Scope. The fade runs on every setEmotion clip change, not only on the post-speech release.

    • The description says authored transitions take precedence. That refers to the _transitions table, but nothing in the repository sends loadTransitionFrames (the bridge only forwards it), so the table stays empty.
    • Authored transition nodes in the pose graph are cross-faded as well.
    • Please limit the fade to the release path the issue describes, or correct the description and show that authored sequences are visually unaffected.
  3. Authored release clips. As noted in #263, we plan to add authored pose-to-idle transition clips. The fade should only be a fallback where no authored release path exists.

  4. Evidence. Please attach a short before/after recording of the default character releasing a pose after speech, with both the image-sequence and the video frame source. Please also run the Electron type check (tsc), since this PR changes TypeScript files.

…talog

- RENDER_POSE_FADE_MS moves from a handwritten config/settings.py
  declaration to config/catalog/graphics/budget.json (integer 0-2000,
  default 200), regenerating settings.py, configCatalog.generated.ts and
  .env.example — unblocks test_config_catalog.
- The cross-fade now runs only on release hops: SpriteForgeRuntime marks
  the post-speech release node play, the release-node advance and the
  release()-to-root return with { release: true }, threaded through
  _playNode to SpriteRenderer.setEmotion. Authored sequences and
  interactive poses no longer get an overlay; authored transition clips
  still take precedence, so the fade stays the fallback when the planned
  authored release clips land.
- Tests: new non-release no-fade case; existing fade cases pass the
  release flag.
@sanketpatel32

Copy link
Copy Markdown
Contributor Author

Requested changes addressed in d1e255a:

  • Catalog. RENDER_POSE_FADE_MS now lives in config/catalog/graphics/budget.json (integer 0–2000, default 200); settings.py, configCatalog.generated.ts and .env.example regenerated. The handwritten declaration is removed, so the catalog CI check passes.
  • Scoped to the release path. SpriteForgeRuntime marks only the three release hops with { release: true } (post-speech release node, release-node advance back to root, and release()), threaded through _playNode → setEmotion(emotion, { release }). Authored sequences and interactive poses no longer get the overlay — covered by a new non-release clip change keeps the hard cut test.
  • Fallback only. Authored transition clips still take precedence over the fade (existing test retained), so when authored release sequences land they win automatically.
  • npx tsc --noEmit -p tsconfig.json clean; node --test tests/sprite_pose_fade.test.cjs 6/6.

Outstanding: the before/after recording of the default character releasing after speech (image-sequence and video frame source) still needs a staged run — flagging rather than fabricating it.

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.

[Feature] Pose release has no transition: hard cut back to standing after speech / 语音结束后姿势回到站立是硬切

2 participants