performance.now() bypasses Host and uses std::time::Instant (unsupported on wasm32-unknown-unknown)

Open
#165 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust, wasm

Research direction

Start with core/src/builtins/global.rs:11 and follow the call to agent::monotonic_ms in core/src/builtins/agent.rs:75; then inspect the Host trait, Host::now_ms, and WebHost. Add a host-provided monotonic clock with a native default and browser implementation. Done when performance.now() uses that clock, native behavior remains available, and the wasm browser path no longer calls unsupported Instant::now().

Written by the indexing model from the issue text.

Description

bug

performance.now(), installed by Context::install_qjs_helpers, reads std::time::Instant directly (core/src/builtins/global.rs:11 -> agent::monotonic_ms, core/src/builtins/agent.rs:75) instead of going through the Host.

Consequences:

  • An embedder cannot control or fake the monotonic clock the way Host::now_ms controls Date.now() (reproducible runs, tests).
  • std::time::Instant::now() is unsupported on wasm32-unknown-unknown (std panics, and the web profile is panic = "abort"), so a browser embedder that installs the qjs helpers would abort on the first performance.now() call. Not exercised today because the web binding does not install the helpers.

Suggestion: add a Host method for the monotonic clock (default: Instant on native) and implement it in WebHost with the browser's performance.now().

Dominant language
Rust
Stars
61
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pocket-stack/quickjs-oxide

All issues in pocket-stack/quickjs-oxide

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.