Skip to content

Conversation

makspll
Copy link
Owner

@makspll makspll commented Aug 31, 2025

Summary

  • Moves LanguageExtensions, Language, ScriptAsset and ScriptAssetLoader into new crate bevy_mod_scripting_asset.
  • Adds new ScriptingAssetError purely for use in this crate
  • Adds supported_extensions field to static plugin config
  • Each plugin now gets its own asset loader with different set of extensions supported, this means we no longer rely on App::finalise collecting supported extensions from a resource near the end of setup, preventing the footgun with ordering here
  • ConfigureScriptAssetSettings trait is removed and its functionality lumped into the ConfigureScriptPlugin trait via add_supported_extension and remove_supported_extension, plugins will now declare their language as well as list of extensions completely independently, yet the user will still have full control

Migration Guide

  • References previously resident in bevy_mod_scripting_core::asset/bevy_mod_scripting::core::asset will now need to come from bevy_mod_scripting_asset or bevy_mod_scripting::asset
  • Adding supported extensions will now need to be done via scripting_plugin.add_supported_extension("extension") rather than via the app directly
  • Plugin implementors will need to add the new crate as a dependency and should not directly rely on the top workspace crate

Copy link

semanticdiff-com bot commented Aug 31, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/prelude.rs  41% smaller
  crates/testing_crates/script_integration_test_harness/src/scenario.rs  40% smaller
  crates/bevy_mod_scripting_functions/src/core.rs  36% smaller
  crates/bevy_mod_scripting_core/src/lib.rs  4% smaller
  crates/bevy_mod_scripting_core/src/asset.rs  3% smaller
  crates/bevy_mod_scripting_core/src/script/mod.rs  2% smaller
  Cargo.toml Unsupported file format
  assets/tests/add_system/added_systems_run_in_parallel.lua  0% smaller
  assets/tests/add_system/added_systems_run_in_parallel.rhai Unsupported file format
  crates/bevy_mod_scripting_asset/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_asset/readme.md Unsupported file format
  crates/bevy_mod_scripting_asset/src/error.rs  0% smaller
  crates/bevy_mod_scripting_asset/src/language.rs  0% smaller
  crates/bevy_mod_scripting_asset/src/lib.rs  0% smaller
  crates/bevy_mod_scripting_asset/src/loader.rs  0% smaller
  crates/bevy_mod_scripting_asset/src/script_asset.rs  0% smaller
  crates/bevy_mod_scripting_core/Cargo.toml Unsupported file format
  crates/bevy_mod_scripting_core/src/bindings/function/script_function.rs  0% smaller
  crates/bevy_mod_scripting_core/src/bindings/globals/core.rs  0% smaller
  crates/bevy_mod_scripting_core/src/bindings/world.rs  0% smaller
  crates/bevy_mod_scripting_core/src/commands.rs  0% smaller
  crates/bevy_mod_scripting_core/src/config.rs  0% smaller
  crates/bevy_mod_scripting_core/src/event.rs  0% smaller
  crates/bevy_mod_scripting_functions/Cargo.toml Unsupported file format
  crates/languages/bevy_mod_scripting_lua/Cargo.toml Unsupported file format
  crates/languages/bevy_mod_scripting_lua/src/bindings/script_value.rs  0% smaller
  crates/languages/bevy_mod_scripting_lua/src/lib.rs  0% smaller
  crates/languages/bevy_mod_scripting_rhai/Cargo.toml Unsupported file format
  crates/languages/bevy_mod_scripting_rhai/src/bindings/script_value.rs  0% smaller
  crates/languages/bevy_mod_scripting_rhai/src/lib.rs  0% smaller
  crates/testing_crates/script_integration_test_harness/Cargo.toml Unsupported file format
  crates/testing_crates/script_integration_test_harness/src/parse.rs  0% smaller
  crates/testing_crates/script_integration_test_harness/src/test_functions.rs  0% smaller
  src/lib.rs  0% smaller

@makspll makspll changed the title refactor: extract bevy_mod_scripting_asset refactor: extract bevy_mod_scripting_asset crate Aug 31, 2025
@makspll makspll changed the title refactor: extract bevy_mod_scripting_asset crate refactor: extract bevy_mod_scripting_asset crate, simplify supported extensions logic Aug 31, 2025
@makspll makspll enabled auto-merge (squash) August 31, 2025 11:13
Copy link
Contributor

github-actions bot commented Aug 31, 2025

🐰 Bencher Report

Branchrefactor/extract-assets-crate
Testbedlinux-gha
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
nanoseconds (ns)
(Result Δ%)
Upper Boundary
nanoseconds (ns)
(Limit %)
component/access Lua📈 view plot
🚷 view threshold
4,247.90 ns
(+4.79%)Baseline: 4,053.84 ns
4,314.00 ns
(98.47%)
component/access Rhai📈 view plot
🚷 view threshold
5,486.40 ns
(-6.52%)Baseline: 5,869.33 ns
6,362.11 ns
(86.24%)
component/get Lua📈 view plot
🚷 view threshold
2,417.60 ns
(-0.92%)Baseline: 2,439.93 ns
2,659.61 ns
(90.90%)
component/get Rhai📈 view plot
🚷 view threshold
4,074.60 ns
(-6.75%)Baseline: 4,369.47 ns
4,843.54 ns
(84.12%)
conversions/Mut::from📈 view plot
🚷 view threshold
91.52 ns
(+4.50%)Baseline: 87.58 ns
93.32 ns
(98.06%)
conversions/Ref::from📈 view plot
🚷 view threshold
87.44 ns
(+2.69%)Baseline: 85.16 ns
88.92 ns
(98.35%)
conversions/ScriptValue::List📈 view plot
🚷 view threshold
285.22 ns
(-0.11%)Baseline: 285.53 ns
328.70 ns
(86.77%)
conversions/ScriptValue::Map📈 view plot
🚷 view threshold
1,343.30 ns
(+13.51%)Baseline: 1,183.41 ns
1,598.11 ns
(84.06%)
conversions/ScriptValue::Reference::from_into📈 view plot
🚷 view threshold
31.82 ns
(+26.22%)Baseline: 25.21 ns
32.69 ns
(97.35%)
conversions/Val::from_into📈 view plot
🚷 view threshold
410.72 ns
(+33.07%)Baseline: 308.65 ns
414.99 ns
(98.97%)
function/call 4 args Lua📈 view plot
🚷 view threshold
1,604.70 ns
(-14.28%)Baseline: 1,872.08 ns
2,163.97 ns
(74.16%)
function/call 4 args Rhai📈 view plot
🚷 view threshold
1,282.70 ns
(-16.13%)Baseline: 1,529.40 ns
1,807.63 ns
(70.96%)
function/call Lua📈 view plot
🚷 view threshold
238.00 ns
(-1.95%)Baseline: 242.74 ns
264.69 ns
(89.92%)
function/call Rhai📈 view plot
🚷 view threshold
405.32 ns
(-12.68%)Baseline: 464.20 ns
536.71 ns
(75.52%)
loading/empty Lua📈 view plot
🚷 view threshold
53,930.00 ns
(-15.70%)Baseline: 63,976.90 ns
73,834.38 ns
(73.04%)
loading/empty Rhai📈 view plot
🚷 view threshold
381,560.00 ns
(+0.34%)Baseline: 380,250.00 ns
448,417.56 ns
(85.09%)
math/vec mat ops Lua📈 view plot
🚷 view threshold
7,601.10 ns
(-3.84%)Baseline: 7,905.00 ns
9,153.70 ns
(83.04%)
math/vec mat ops Rhai📈 view plot
🚷 view threshold
6,221.50 ns
(-7.32%)Baseline: 6,712.67 ns
7,446.43 ns
(83.55%)
query/10 entities Lua📈 view plot
🚷 view threshold
20,575.00 ns
(-1.63%)Baseline: 20,916.20 ns
22,292.59 ns
(92.30%)
query/10 entities Rhai📈 view plot
🚷 view threshold
18,452.00 ns
(-10.26%)Baseline: 20,561.80 ns
22,898.88 ns
(80.58%)
query/100 entities Lua📈 view plot
🚷 view threshold
40,528.00 ns
(-5.14%)Baseline: 42,725.00 ns
45,188.22 ns
(89.69%)
query/100 entities Rhai📈 view plot
🚷 view threshold
33,534.00 ns
(+0.43%)Baseline: 33,389.10 ns
35,721.17 ns
(93.88%)
query/1000 entities Lua📈 view plot
🚷 view threshold
276,280.00 ns
(-1.18%)Baseline: 279,569.00 ns
299,446.36 ns
(92.26%)
query/1000 entities Rhai📈 view plot
🚷 view threshold
173,380.00 ns
(+1.77%)Baseline: 170,361.00 ns
183,023.31 ns
(94.73%)
reflection/10 Lua📈 view plot
🚷 view threshold
5,660.90 ns
(-8.85%)Baseline: 6,210.51 ns
6,847.44 ns
(82.67%)
reflection/10 Rhai📈 view plot
🚷 view threshold
14,634.00 ns
(-7.49%)Baseline: 15,819.50 ns
17,043.21 ns
(85.86%)
reflection/100 Lua📈 view plot
🚷 view threshold
47,195.00 ns
(-8.10%)Baseline: 51,352.30 ns
57,061.66 ns
(82.71%)
reflection/100 Rhai📈 view plot
🚷 view threshold
734,450.00 ns
(-4.08%)Baseline: 765,706.00 ns
832,502.14 ns
(88.22%)
resource/access Lua📈 view plot
🚷 view threshold
3,784.20 ns
(+4.17%)Baseline: 3,632.88 ns
3,888.66 ns
(97.31%)
resource/access Rhai📈 view plot
🚷 view threshold
5,033.90 ns
(-5.54%)Baseline: 5,329.07 ns
5,742.42 ns
(87.66%)
resource/get Lua📈 view plot
🚷 view threshold
1,977.30 ns
(-4.43%)Baseline: 2,068.87 ns
2,278.04 ns
(86.80%)
resource/get Rhai📈 view plot
🚷 view threshold
3,619.10 ns
(-6.62%)Baseline: 3,875.79 ns
4,271.82 ns
(84.72%)
🐰 View full continuous benchmarking report in Bencher

@makspll makspll merged commit 3004915 into main Aug 31, 2025
30 of 33 checks passed
@makspll makspll deleted the refactor/extract-assets-crate branch August 31, 2025 11:51
@github-actions github-actions bot mentioned this pull request Aug 31, 2025
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.

1 participant