Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wasm non-web usage of env::now #123

Merged
merged 2 commits into from
Jan 30, 2023
Merged

Fix wasm non-web usage of env::now #123

merged 2 commits into from
Jan 30, 2023

Conversation

bnjbvr
Copy link
Contributor

@bnjbvr bnjbvr commented Jan 30, 2023

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

A wasm embedder that hasn't enabled the web feature will still get the Instant::now() function generated, even if they end up using a custom now function. After all, the compiler/link don't have runtime knowledge about how the program runs, so it could be that ThreadProfiler::initialize is never called, so the default value of now_ns that makes use of Instant::now could be called at any point.

This changes the now_ns function so it's defined only using Instant for native target and wasm when web is enabled. In the other case, we assume this is never called and it's a programmer error because we don't have any time reporter. I didn't want to cause a panic! in there, so returned a dummy value instead; let me know what you think is preferred.

Related Issues

Fixes #118.

puffin/src/lib.rs Outdated Show resolved Hide resolved
@TimonPost TimonPost merged commit b9b4e6e into main Jan 30, 2023
@TimonPost TimonPost deleted the fix-wasm-non-web branch January 30, 2023 20:00
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.

Upgrading from 0.14.0 to 0.14.1 breaks compatibility with wasm32-unknown-unknown target
4 participants