Skip to content

fix(overlay,sync): enforce zero-retained FighterEngine lifecycle and <45ms esp32dev wheel sync for v4.3.9 - #88

Merged
red77290 merged 4 commits into
mainfrom
fix/overlay-ephemeral-and-sync-latency
Dec 2, 2026
Merged

red77290 merged 4 commits into
mainfrom
fix/overlay-ephemeral-and-sync-latency

Conversation

@red77290

@red77290 red77290 commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Summary

Backs the v4.3.9-beta1 pre-release (prerelease: true, make_latest: false — keeping v4.3.8 as the stable Latest release during hardware validation).

Root Causes Addressed

  1. Permanent FighterEngine Heap Retention Across Rotation & FrontendSync (ESP32 & ESP32-S3):
    • OverlayManager previously kept FighterEngine (FgtLoader worker stack + m_roster + animation headers ~22 KB idle, up to ~38 KB during active scanline streaming) alive across rotation switches, between fights, and during FrontendSync (DisplayRuntime::render() also forced FighterOverride::Enabled on MQTT / MARQUEE).
    • On Clock + Fighters -> GIFs rotation switches on esp32dev, RotationManager::switchToModule() ran before DisplayRuntime::render() deactivated the overlay, and GifEngine::activate() spawned gif_preload (8 KB stack) before allocating AnimatedGIF (22,608 B contiguous). AnimatedGIF allocation failed -> isFinished() == true -> rotation immediately bounced back to Clock + Fighters (16 ms).
    • During FrontendSync, pinning 8-bit HUB75 DMA (4 KB threshold in GifEngine::refineDynamicRequirements()) while FighterEngine retained ~22 KB starved LitePngDecoder (causing text-only marquees) and LwIP TCP RX pbuf pools (causing lag/retransmissions).
  2. 100 ms/step Wheel Navigation Skipping Intermediate Logos on Local-SD esp32dev:
    • FrontendSyncEngine::scheduleOrDispatchArtJob() applied a 35 ms Tier-2 network settle delay on top of a 40 ms Tier-1 debounce and 10 ms worker wake slices on !hasPsram (~85–95 ms pre-open latency), causing 100 ms/step wheel navigation (simulate_recalbox_sync.py) to overwrite intermediate games before opening their marquee.

Key Changes

  • OverlayManager & FighterEngine (ADR-0004):
    • Zero retained memory across both esp32dev and ESP32-S3: FighterEngine is destroyed via Core0LifecycleDispatcher immediately after each fight (0 B held during the inter-fight cooldown), across every rotation slot switch, on deactivation, and on FrontendSync preemption.
    • Added OverlayManager::evictForMemory() (retireFighterOverlay(true)) and called it in RotationManager::switchToModule(), evictAllActiveEnginesForMemory(), and DisplayRuntime::transitionSession() before HUB75 DMA depth evaluation or decoder allocation.
    • Scoped OverlayManager strictly to DisplaySourceId::ROTATION when activeEngine->allowsOverlay() == true (never active on MQTT, MARQUEE, or GifEngine playlists).
    • Moved loadRoster() and post-fight freeFighter() off Core 1 onto Core 0, added SMP-safe signalLoaderStopOnce(), made s_lastInstance atomic, preserved idle_fighter_interval in a rollover-safe 4 B .bss timestamp, and gated instantiation on live internal SRAM / PSRAM headroom.
  • GifEngine:
    • Allocated ensureGifDecoder() (22.6 KB contiguous) and ensureCanvasBuffer() before startPreloadTask() (4 KB stack on !m_hasPsram), and raised static-PNG refineDynamicRequirements() to 18,432 B / 10,240 B (~30 KB total SRAM floor).
  • FrontendSyncEngine:
    • Restored immediate !hasPsram dispatch (0 ms Tier-2 wait on local SD), tightened non-PSRAM Tier-1 burst coalescing to 15 ms (35 ms max), reduced SyncShowcaseWkr wake slices to 2 ms, and added stripped title stems to binarySearchCatalogForGameJob().

Verification

  • python3 ~/.gemini/skills/arcadematrix-dev-guard/scripts/check_compliance.py --with-tests (0 errors, 79/79 native tests passing)
  • python3 scripts/package_tools.py --verify-only && python3 scripts/test_tools_e2e.py
  • PlatformIO 3-target CI + release.yml pre-release build (v4.3.9-beta1, ADR-0006 binary ceiling check)

@red77290 red77290 changed the title fix(overlay,sync): enforce zero-retained FighterEngine lifecycle and <45ms esp32dev wheel sync (v4.3.9-beta1) fix(overlay,sync): enforce zero-retained FighterEngine lifecycle and <45ms esp32dev wheel sync for v4.3.9 Dec 2, 2026
@red77290
red77290 merged commit a0c09ab into main Dec 2, 2026
3 checks passed
@red77290
red77290 deleted the fix/overlay-ephemeral-and-sync-latency branch December 2, 2026 17:28
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.

1 participant