Files
LEDMatrix/test/test_vegas_switch_interval.py
T
ChuckandClaude Opus 5.5 9964dd2183 feat(vegas): render plugin content off the render thread, and keep it off the GIL when the panel needs it (#630)
DisplayManager.offscreen() gives a thread its own canvas, so Vegas renders every plugin's ticker content on its prefetch thread instead of pausing the scroll for canvas-bound plugins on the render thread. A render gate (src/common/render_gate.py, vegas_scroll.prefetch_gate, on by default with the GIL-releasing binding) lets the prefetch thread run Python only while the render thread waits in SwapOnVSync: on hdpi, frames 2+ refreshes late fell eightfold and late frames overall from 0.90% to 0.60%. See docs/OFFSCREEN_RENDERING.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 19:57:03 -04:00

42 lines
1.3 KiB
Python

"""vegas_scroll.switch_interval_ms: applied for a Vegas run, restored after."""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from src.vegas_mode.config import VegasModeConfig # noqa: E402
from src.vegas_mode.coordinator import VegasModeCoordinator # noqa: E402
def _coordinator(ms):
c = VegasModeCoordinator.__new__(VegasModeCoordinator)
c.vegas_config = VegasModeConfig(switch_interval_ms=ms)
return c
def test_applied_for_the_run_and_restored_after():
before = sys.getswitchinterval()
c = _coordinator(1.0)
try:
c._apply_switch_interval()
assert abs(sys.getswitchinterval() - 0.001) < 1e-9
c._apply_switch_interval() # a second start must not lose the original
finally:
c._restore_switch_interval()
assert sys.getswitchinterval() == before
def test_zero_leaves_the_interpreter_alone():
before = sys.getswitchinterval()
c = _coordinator(0.0)
c._apply_switch_interval()
c._restore_switch_interval()
assert sys.getswitchinterval() == before
def test_read_from_config():
config = VegasModeConfig.from_config(
{"display": {"vegas_scroll": {"switch_interval_ms": 1}}})
assert config.switch_interval_ms == 1.0
assert VegasModeConfig.from_config({"display": {"vegas_scroll": {}}}).switch_interval_ms == 0.0