Browser VBlank waits follow requestAnimationFrame frequency in PS1 timing mode

Aperta
#232 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c

Direzione di ricerca

Read psyz/src/platform/sdl3_common.h::WaitForNextFrame and psyz/src/web/web_timing.c to trace how browser callbacks and emulated VBlank timing interact. Start by reproducing the issue with the presentation sample and its controlled timer diagnostic; compare iteration rates at different callback frequencies. Done when internal-limiter PS1 timing follows emulated time within host performance limits, with presentation cadence treated separately.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

In PsyZ 35c673ecf1c4ba799a812d701918c2c52935475b, the browser branch of
WaitForNextFrame waits for one requestAnimationFrame callback per requested
VBlank. It does not use the emulated NTSC/PAL duration there, even when
PSYZ_VSYNC_OFF selects the internal limiter.

Reproduction

Run the shared presentation sample, which selects
NTSC, the internal limiter and a two-VBlank wait per application iteration.
On actual hardware, compare it on different display refresh rates.

For a repeatable software diagnostic, measure.js replaces RAF with
a controlled timer callback before loading the sample. The measured iteration
rate changes substantially with callback frequency:

Requested callback rate Unmodified PsyZ Local timing prototype
30/s 13.3/s 25.8/s
60/s 25.4/s 28.3/s
120/s 44.1/s 28.3/s

Controlled callback experiment

These are software-timer measurements in headless Chromium, not physical
30/60/120 Hz monitor measurements
. Timer, main-loop and rendering overhead are
included. The NTSC two-VBlank target is about 29.97 iterations/s; the local
prototype is closer but this test does not establish perfect pacing.

Expected behavior and scope

Internal-limiter/PS1 timing should be governed by emulated time, independently
of callback frequency, within host performance limits. Presentation cadence and
emulated VBlank advancement are separate concerns. Explicit display-sync or
uncapped modes may intentionally behave differently.

The relevant paths are psyz/src/platform/sdl3_common.h::WaitForNextFrame and
psyz/src/web/web_timing.c. Our current delay-based workaround is evidence for
the diagnosis, not a complete solution for one-VBlank loops, background tabs,
PAL, variable refresh or catch-up policy.

To run the optional timer experiment, install playwright in a scratch directory, save the attached script as measure.cjs (CommonJS), and run:

node measure.cjs http://127.0.0.1:8201/index.html

Set CHROME to your installed Chromium executable, or install Playwright's Chromium with npx playwright install chromium. The script overrides RAF only in its isolated test pages.

Recorded browser environment: Emscripten 6.0.13, Chromium 157 (headless SwiftShader), macOS arm64, device scale factor 1. Comparisons use local port prototypes, not hardware reference captures.

Build and run the standalone presentation sample

Download presentation.c and shell.html into the same directory. No game source, executable or assets are needed. Add this CMakeLists.txt:

cmake_minimum_required(VERSION 3.21)
project(presentation_repro C CXX)
set(CMAKE_C_STANDARD 11)
add_compile_options(-pthread)
add_link_options(-pthread)
set(SDL_PTHREADS ON CACHE BOOL "" FORCE)
add_subdirectory("${PSYZ_ROOT}/psyz" psyz EXCLUDE_FROM_ALL)
add_executable(presentation presentation.c)
target_link_libraries(presentation PRIVATE psyz)
target_link_options(presentation PRIVATE -sASSERTIONS=1 -sPTHREAD_POOL_SIZE=2)
psyz_web_configure_target(presentation OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/site")
get_target_property(options presentation LINK_OPTIONS)
list(FILTER options EXCLUDE REGEX "^--shell-file=")
set_property(TARGET presentation PROPERTY LINK_OPTIONS "${options}")
target_link_options(presentation PRIVATE "--shell-file=${CMAKE_CURRENT_https://github.com/user-attachments/files/34581629/presentation.c_DIR}/shell.html")

Use a PsyZ checkout at the recorded revision, with its SDL submodule initialized:

emcmake cmake -S . -B build -DPSYZ_ROOT=/path/to/psyz -DCMAKE_BUILD_TYPE=Release
cmake --build build -j8

Serve build/site locally with Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp, as required by Emscripten pthreads, then open index.html.

Lingua principale
C
Stelle
107
Fork
26
Merge medio
2g 21h
PR unite (30g)
5

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Xeeynamo/psyz

Tutte le issue di Xeeynamo/psyz

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.