fixed issues with flickering on frame sync

This commit is contained in:
bQUARKz 2026-02-08 12:00:05 +00:00
parent 2fb6fb2cda
commit c68b300d5e
Signed by: bquarkz
SSH Key Fingerprint: SHA256:Z7dgqoglWwoK6j6u4QC87OveEq74WOhFN+gitsxtkf8
2 changed files with 22 additions and 1 deletions

View File

@ -68,6 +68,10 @@ pub struct PrometeuOS {
/// Debugging flag to execute exactly one instruction or frame regardless of budget.
pub debug_step_request: bool,
/// When true, the next logical frame must rearm the entrypoint call before running
/// to avoid resuming at a pending RET after a FRAME_SYNC safe point.
needs_prepare_entry_call: bool,
/// Wall-clock time of system startup.
boot_time: Instant,
}
@ -109,6 +113,7 @@ impl PrometeuOS {
certifier: Certifier::new(cap_config.unwrap_or_default()),
paused: false,
debug_step_request: false,
needs_prepare_entry_call: false,
boot_time,
};
@ -218,8 +223,11 @@ impl PrometeuOS {
// If the VM is not currently executing a function (e.g. at the start of the app
// or after the entrypoint function returned), we prepare a new call to the entrypoint.
if vm.call_stack.is_empty() {
// Additionally, if the previous slice ended with FRAME_SYNC, we must force a rearm
// so we don't resume execution at a pending RET on the next tick.
if self.needs_prepare_entry_call || vm.call_stack.is_empty() {
vm.prepare_call(&self.current_entrypoint);
self.needs_prepare_entry_call = false;
}
// Reset telemetry for the new logical frame
@ -285,6 +293,12 @@ impl PrometeuOS {
self.logical_frame_active = false;
self.logical_frame_remaining_cycles = 0;
// If the slice ended in FRAME_SYNC, ensure the next tick starts a fresh
// call to the entrypoint instead of resuming at the RET that follows.
if run.reason == LogicalFrameEndingReason::FrameSync {
self.needs_prepare_entry_call = true;
}
// If we were doing a "step frame" debug command, pause now that the frame is done.
if self.debug_step_request {
self.paused = true;

7
test-cartridges/test01/run.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/zsh
set -e
sdk/prometeu build .
cp build/program.pbc cartridge/program.pbc
sdk/prometeu run cartridge