Skip to content

simulation: keep polling the real-time outputs while the table is paused - #657

Merged
freezy merged 1 commit into
masterfrom
fix/realtime-poll-while-paused
Dec 1, 2026
Merged

freezy merged 1 commit into
masterfrom
fix/realtime-poll-while-paused

Conversation

@freezy

@freezy freezy commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

A game without a time fence keeps running while the table is paused, and so do its lamps. Nobody polled its real-time output feed until the table resumed, so the feed overflowed and DOF switched off for the rest of the game.

The simulation thread's paused loop now polls the real-time outputs every 10 ms, without moving the time fence.

Summary by CodeRabbit

  • New Features
    • Real-time outputs are now polled approximately every 10 ms while the table is paused, so connected outputs can continue updating without advancing simulation time.
    • When the simulation thread is not running, real-time outputs continue to be polled once per frame.

A game without a time fence keeps running during a pause, and so do its lamps. Nobody polled its real-time feed until the resume, so it overflowed and DOF switched off for the rest of the game. The paused loop now polls every 10 ms without moving the time fence.
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes: Paused real-time output polling

Layer / File(s) Summary
Paused polling behavior
VisualPinball.Unity/VisualPinball.Unity/Simulation/SimulationThread.cs, VisualPinball.Unity/VisualPinball.Unity/Plugins/RealtimeOutputPoll.cs, VisualPinball.Unity/VisualPinball.Unity/Plugins/UnityPluginContracts.cs
While paused, the simulation thread polls real-time outputs before sleeping for 10 ms. Documentation describes the polling schedule and states that paused reports do not accumulate until resume. The time fence does not move during paused polling.

Possibly related PRs

  • freezy/VisualPinball.Engine#648: Adds the RealtimeOutputs resource polled by the simulation thread. This change adds polling of that resource while paused.

Change: Bug fix

Merge Risk: Minimal · up to 900fe

Real-time outputs now keep being polled while the table is paused, which prevents the output feed from overflowing. No merge-blocking risk was found.

Security architecture risk: Minimal · up to 900fe

The change keeps the existing cabinet output feed draining while the table is paused, without advancing the game clock or giving new recipients access. The review found no material new security or failure-containment risk.

Security review details

Security Blast Radius

  • observed — The change extends the delivery window for the existing engine feed and its existing subscribers, including cabinet-output consumers. The paused call does not check whether the engine uses a time fence, but it does require an active listener.

Trust Boundaries and Controls

  • observed — The paused call reaches the same engine callback and listener as active polling. Listener teardown clears the poll gate before detaching the listener, so subsequent checks skip polling; the gate does not cancel a poll already in flight.

Resilience and Maintainability Implications

  • observed — Callback exceptions still use throttled logging and return control to the loop. The frame path remains gated while the simulation thread owns polling, and the loop releases ownership in its existing finally block when it exits normally or faults.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c0ea4bf1-d896-45c2-a0ee-9844f65b62a6
Commits

Reviewing files that changed from the base of the PR and between e97e808 and 900fe04.

Files selected for processing: 3

  • VisualPinball.Unity/VisualPinball.Unity/Plugins/RealtimeOutputPoll.cs
  • VisualPinball.Unity/VisualPinball.Unity/Plugins/UnityPluginContracts.cs
  • VisualPinball.Unity/VisualPinball.Unity/Simulation/SimulationThread.cs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5RetriggerView in Greptile

[Medium impact] The change affects real-time output polling for games that use a simulation thread.

The PR appears safe to merge, with a non-blocking request to test polling during pause.

Findings

  1. P2 Paused polling lacks test coverage ▶

Summary

Keeps real-time outputs flowing while the table is paused.

  • Paused tables keep real-time output feeds moving.

Reviews (1) · Last reviewed commit: "simulation: keep polling the real-time o..." · Reviewed by Greptile

{
// A game without a time fence keeps running while the table is paused, and so do its
// lamps. Keep taking its real-time outputs, or they pile up until the resume and overflow.
_realtimeOutputs?.PollFromSimulationThread();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Paused polling lacks test coverage

The new paused-loop poll has no regression test. TheSimulationThreadTakesOverThePollFromTheFrame calls the poll helper directly, so it would still pass if this line were removed. Add a test that pauses the simulation, checks that outputs keep arriving, and checks that the time fence stays fixed.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Not adding one here. Testing this line means running the real simulation thread, and its loop only starts after a fully initialized physics engine (it waits for PhysicsEngine.IsInitialized, then gives up after 5 s). No test in the suite starts the thread; the existing ones call its methods directly. A test that pauses the running thread would need that harness first, which is out of scope for this fix.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That’s fair. A regression test for this line would require bringing up the initialized physics engine and running the simulation thread, and the existing tests don’t provide that harness. I’ll withdraw the test-coverage comment for this change; the direct helper test is not a substitute for exercising the paused loop, but adding that infrastructure is out of scope here.

@freezy
freezy merged commit 827b8ab into master Dec 1, 2026
21 of 22 checks passed
@freezy
freezy deleted the fix/realtime-poll-while-paused branch December 1, 2026 23:33
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