Skip to content

fix: Use bevy_platform::time::Instant in the script pipeline#543

Merged
makspll merged 3 commits into
makspll:mainfrom
ianm199:wasm-platform-instant
May 27, 2026
Merged

fix: Use bevy_platform::time::Instant in the script pipeline#543
makspll merged 3 commits into
makspll:mainfrom
ianm199:wasm-platform-instant

Conversation

@ianm199
Copy link
Copy Markdown
Contributor

@ianm199 ianm199 commented May 26, 2026

pipeline/machines.rs uses std::time::Instant, which doesn't work on wasm:

  • std::time::Instant::now() panics at runtime on wasm32-unknown-unknown ("time not implemented on this platform"); the machine tick loop calls it every frame.
  • bevy_platform::time::Instant is already a dependency here — it's std::time::Instant on native and web_time on wasm. Same API, no behavior change off wasm, no new dep.

Towards #166.

std::time::Instant::now() panics at runtime on wasm32-unknown-unknown.
@ianm199 ianm199 mentioned this pull request May 26, 2026
@semanticdiff-com
Copy link
Copy Markdown

semanticdiff-com Bot commented May 26, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  crates/bevy_mod_scripting_bindings/src/function/script_function.rs  0% smaller
  crates/bevy_mod_scripting_core/src/pipeline/machines.rs  0% smaller
  rust-toolchain.toml Unsupported file format

@makspll makspll self-requested a review May 27, 2026 18:57
@makspll makspll changed the title Use bevy_platform::time::Instant in the script pipeline fix: Use bevy_platform::time::Instant in the script pipeline May 27, 2026
@makspll makspll enabled auto-merge (squash) May 27, 2026 18:58
CI is red on every job, but not from this change: the benchmark/diff jobs
fail installing bencher because its current source uses Duration::from_hours,
which is only const-stable on Rust >= 1.91, while rust-toolchain.toml pins
1.89.0. The build/test matrix also trips over the pinned toolchain (clippy
component missing) and gets cancelled by fail-fast. Bump the pin to 1.91.0
and declare the clippy/rustfmt components so the toolchain is complete.
auto-merge was automatically disabled May 27, 2026 19:59

Head branch was pushed to by a user without write access

@ianm199
Copy link
Copy Markdown
Contributor Author

ianm199 commented May 27, 2026

Pushed a commit to fix CI. It was red across the board, but not because of this change.

The benchmark and diff jobs fail while installing bencher, because bencher's current source uses Duration::from_hours, which is only const-stable on Rust 1.91 and up, while rust-toolchain.toml pins 1.89.0. The build and test matrix also trips on the pinned toolchain (clippy component missing) and then gets cancelled by fail-fast.

I bumped rust-toolchain.toml to 1.91.0 and declared the clippy and rustfmt components. Mind approving the workflow run so it can go again? Happy to split the toolchain bump into its own PR if you'd rather keep this one to just the Instant change.

@makspll makspll enabled auto-merge (squash) May 27, 2026 20:22
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Binding Differences Detected

The following changes were detected in generated bindings:

b/crates/bindings/bevy_asset_bms_bindings/src/lib.rs
index 776c17c..312c549 100644
--- a/crates/bindings/bevy_asset_bms_bindings/src/lib.rs
+++ b/crates/bindings/bevy_asset_bms_bindings/src/lib.rs
@@ -334,7 +334,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise negation (`!`) of the bits in a flags value, truncating the result.",
+            " The bitwise negation (`!`) of the bits in `self`, truncating the result.",
             &["_self"],
         )
         .register_documented(
@@ -355,7 +355,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " Whether all set bits in a source flags value are also set in a target flags value.",
+            " Whether all set bits in `other` are also set in `self`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -376,7 +376,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The intersection of a source flags value with the complement of a target flags\n value (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
+            " The intersection of `self` with the complement of `other` (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
             &["_self", "other"],
         )
         .register_documented(
@@ -466,7 +466,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise or (`|`) of the bits in two flags values.",
+            " The bitwise or (`|`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -487,7 +487,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise and (`&`) of the bits in two flags values.",
+            " The bitwise and (`&`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -508,7 +508,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " Whether any set bits in a source flags value are also set in a target flags value.",
+            " Whether any set bits in `other` are also set in `self`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -542,7 +542,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " Whether all bits in this flags value are unset.",
+            " Whether all bits in `self` are unset.",
             &["_self"],
         )
         .register_documented(
@@ -563,7 +563,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The intersection of a source flags value with the complement of a target flags\n value (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `remove` won't truncate `other`, but the `!` operator will.",
+            " The intersection of `self` with the complement of `other` (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `remove` won't truncate `other`, but the `!` operator will.",
             &["_self", "other"],
         )
         .register_documented(
@@ -606,7 +606,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The intersection of a source flags value with the complement of a target flags value (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
+            " The intersection of `self` with the complement of `other` (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
             &["_self", "other"],
         )
         .register_documented(
@@ -627,7 +627,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise exclusive-or (`^`) of the bits in two flags values.",
+            " The bitwise exclusive-or (`^`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -648,7 +648,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise exclusive-or (`^`) of the bits in two flags values.",
+            " The bitwise exclusive-or (`^`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -669,7 +669,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise or (`|`) of the bits in two flags values.",
+            " The bitwise or (`|`) of the bits in `self` and `other`.",
             &["_self", "other"],
         );
     let registry = world.get_resource_or_init::();

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

🐰 Bencher Report

Branchwasm-platform-instant
Testbedlinux-gha

⚠️ WARNING: Truncated view!

The full continuous benchmarking report exceeds the maximum length allowed on this platform.

🚨 5 Alerts

🐰 View full continuous benchmarking report in Bencher

Rust 1.91 renders the elided lifetime in std::any::type_name output, so
ScriptFunction<fn(..)> is now ScriptFunction<'_, fn(..)>. Update the
hardcoded expected function name in test_invalid_amount_of_args_errors_nicely
to match. Companion to the 1.91 toolchain bump.
auto-merge was automatically disabled May 27, 2026 20:56

Head branch was pushed to by a user without write access

@ianm199
Copy link
Copy Markdown
Contributor Author

ianm199 commented May 27, 2026

One more commit. With the toolchain on 1.91, the only remaining failure was test_invalid_amount_of_args_errors_nicely: Rust 1.91 now renders the elided lifetime in std::any::type_name, so the expected ScriptFunction<fn(..)> is now ScriptFunction<'_, fn(..)>. Updated that hardcoded string. Benchmarks and bindings sync already went green on 1.91. Mind approving the run once more?

@ianm199
Copy link
Copy Markdown
Contributor Author

ianm199 commented May 27, 2026

@makspll I confirmed this last one actually runs locally - sorry for all the back and forth. This should unblock other open PRs as well since the pipeline has been broke

@makspll makspll enabled auto-merge (squash) May 27, 2026 21:46
@makspll
Copy link
Copy Markdown
Owner

makspll commented May 27, 2026

All good! Thanks for the contribution :D

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Binding Differences Detected

The following changes were detected in generated bindings:

b/crates/bindings/bevy_asset_bms_bindings/src/lib.rs
index 776c17c..312c549 100644
--- a/crates/bindings/bevy_asset_bms_bindings/src/lib.rs
+++ b/crates/bindings/bevy_asset_bms_bindings/src/lib.rs
@@ -334,7 +334,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise negation (`!`) of the bits in a flags value, truncating the result.",
+            " The bitwise negation (`!`) of the bits in `self`, truncating the result.",
             &["_self"],
         )
         .register_documented(
@@ -355,7 +355,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " Whether all set bits in a source flags value are also set in a target flags value.",
+            " Whether all set bits in `other` are also set in `self`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -376,7 +376,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The intersection of a source flags value with the complement of a target flags\n value (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
+            " The intersection of `self` with the complement of `other` (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
             &["_self", "other"],
         )
         .register_documented(
@@ -466,7 +466,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise or (`|`) of the bits in two flags values.",
+            " The bitwise or (`|`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -487,7 +487,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise and (`&`) of the bits in two flags values.",
+            " The bitwise and (`&`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -508,7 +508,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " Whether any set bits in a source flags value are also set in a target flags value.",
+            " Whether any set bits in `other` are also set in `self`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -542,7 +542,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " Whether all bits in this flags value are unset.",
+            " Whether all bits in `self` are unset.",
             &["_self"],
         )
         .register_documented(
@@ -563,7 +563,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The intersection of a source flags value with the complement of a target flags\n value (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `remove` won't truncate `other`, but the `!` operator will.",
+            " The intersection of `self` with the complement of `other` (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `remove` won't truncate `other`, but the `!` operator will.",
             &["_self", "other"],
         )
         .register_documented(
@@ -606,7 +606,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The intersection of a source flags value with the complement of a target flags value (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
+            " The intersection of `self` with the complement of `other` (`&!`).\n This method is not equivalent to `self & !other` when `other` has unknown bits set.\n `difference` won't truncate `other`, but the `!` operator will.",
             &["_self", "other"],
         )
         .register_documented(
@@ -627,7 +627,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise exclusive-or (`^`) of the bits in two flags values.",
+            " The bitwise exclusive-or (`^`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -648,7 +648,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise exclusive-or (`^`) of the bits in two flags values.",
+            " The bitwise exclusive-or (`^`) of the bits in `self` and `other`.",
             &["_self", "other"],
         )
         .register_documented(
@@ -669,7 +669,7 @@ pub(crate) fn register_render_asset_usages_functions(world: &mut World) {
                 };
                 output
             },
-            " The bitwise or (`|`) of the bits in two flags values.",
+            " The bitwise or (`|`) of the bits in `self` and `other`.",
             &["_self", "other"],
         );
     let registry = world.get_resource_or_init::();

@makspll makspll merged commit 777353d into makspll:main May 27, 2026
25 checks passed
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.

2 participants