bevy_mod_scripting icon indicating copy to clipboard operation
bevy_mod_scripting copied to clipboard

feat!: Update to Bevy 0.16

Open alexparlett opened this issue 6 months ago • 2 comments

Summary

This introduces Bevy 0.16 compatibility.

We should probably in a follow up move to the bevy::platform::collections instead of using std to try and align as closely as possible with the no std approach bevy is taking but i didn't want to do it in this one.

Need to quickly restore the ordering where my ide aligned them with the interface order, but thought it would be good to get visibility on the changes.

Notes

bevy_console is pointing at a branch - there is https://github.com/RichoDemus/bevy-console/pull/88/files awaiting review which would allow us to change this.

alexparlett avatar May 22 '25 06:05 alexparlett

  • [x] bevy console 0.14.0 released

makspll avatar May 28 '25 11:05 makspll

Is there anything holding this up? Formatting needs to be fixed up, anything else to do?

CrushedPixel avatar Jun 15 '25 12:06 CrushedPixel

I'm curious too about the fate of this PR.

shanecelis avatar Jun 26 '25 05:06 shanecelis

Bump on getting this landed?

Nub avatar Jul 02 '25 02:07 Nub

I'm anxious for this PR to land, and I inadvertently did a big overhaul with PR #427 to use handles rather than script IDs, so to make amends I handled the merge conflicts to create #431 which contains both handles and 0.16 support.

shanecelis avatar Jul 02 '25 10:07 shanecelis

Looking at this now, it looks like there is still some work left on the codegen side which is currently failing. Did you update the generated bindings manually 👀

makspll avatar Jul 03 '25 22:07 makspll

🐰 Bencher Report

Branchbevy_0.16
Testbedlinux-gha

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencynanoseconds (ns)
component/access Lua📈 view plot
⚠️ NO THRESHOLD
3,542.80 ns
component/access Rhai📈 view plot
⚠️ NO THRESHOLD
5,236.30 ns
component/get Lua📈 view plot
⚠️ NO THRESHOLD
2,182.50 ns
component/get Rhai📈 view plot
⚠️ NO THRESHOLD
3,970.00 ns
conversions/Mut::from📈 view plot
⚠️ NO THRESHOLD
83.30 ns
conversions/Ref::from📈 view plot
⚠️ NO THRESHOLD
83.31 ns
conversions/ScriptValue::List📈 view plot
⚠️ NO THRESHOLD
281.54 ns
conversions/ScriptValue::Map📈 view plot
⚠️ NO THRESHOLD
1,417.80 ns
conversions/ScriptValue::Reference::from_into📈 view plot
⚠️ NO THRESHOLD
26.26 ns
conversions/Val::from_into📈 view plot
⚠️ NO THRESHOLD
279.74 ns
function/call 4 args Lua📈 view plot
⚠️ NO THRESHOLD
1,643.50 ns
function/call 4 args Rhai📈 view plot
⚠️ NO THRESHOLD
1,319.30 ns
function/call Lua📈 view plot
⚠️ NO THRESHOLD
235.06 ns
function/call Rhai📈 view plot
⚠️ NO THRESHOLD
390.37 ns
loading/empty Lua📈 view plot
⚠️ NO THRESHOLD
48,153.00 ns
loading/empty Rhai📈 view plot
⚠️ NO THRESHOLD
684,620.00 ns
math/vec mat ops Lua📈 view plot
⚠️ NO THRESHOLD
6,807.20 ns
math/vec mat ops Rhai📈 view plot
⚠️ NO THRESHOLD
6,234.10 ns
query/10 entities Lua📈 view plot
⚠️ NO THRESHOLD
18,918.00 ns
query/10 entities Rhai📈 view plot
⚠️ NO THRESHOLD
17,871.00 ns
query/100 entities Lua📈 view plot
⚠️ NO THRESHOLD
37,402.00 ns
query/100 entities Rhai📈 view plot
⚠️ NO THRESHOLD
31,556.00 ns
query/1000 entities Lua📈 view plot
⚠️ NO THRESHOLD
233,200.00 ns
query/1000 entities Rhai📈 view plot
⚠️ NO THRESHOLD
177,570.00 ns
reflection/10 Lua📈 view plot
⚠️ NO THRESHOLD
5,502.90 ns
reflection/10 Rhai📈 view plot
⚠️ NO THRESHOLD
14,997.00 ns
reflection/100 Lua📈 view plot
⚠️ NO THRESHOLD
46,307.00 ns
reflection/100 Rhai📈 view plot
⚠️ NO THRESHOLD
725,030.00 ns
resource/access Lua📈 view plot
⚠️ NO THRESHOLD
3,159.60 ns
resource/access Rhai📈 view plot
⚠️ NO THRESHOLD
4,678.50 ns
resource/get Lua📈 view plot
⚠️ NO THRESHOLD
1,809.50 ns
resource/get Rhai📈 view plot
⚠️ NO THRESHOLD
3,329.40 ns
🐰 View full continuous benchmarking report in Bencher

github-actions[bot] avatar Jul 03 '25 23:07 github-actions[bot]

The good news is it seems the new rustup version didn't break the codegen crate (i.e. it does not require a rustc_plugin version bump, which is always the most painful bit)

Codegen seems to need a few small adjustments and we should be good to go

makspll avatar Jul 05 '25 10:07 makspll

I've had my yearly fight with rust analyzer now, a few little changes to go, unwraps etc...

EDIT: looks like some tests are failing

makspll avatar Jul 06 '25 21:07 makspll

FYI to those who have been using this branch, bevy shuffled around many types, which will be reflected in the new codegen (including the bindings features), things that used to live in bevy_core, and bevy_hierarchy like Name seem to have been moved to bevy_ecs

makspll avatar Jul 07 '25 19:07 makspll

I found a weird error trying to migrate to this and made a repo that reproduces it. it basically boils down to this binding not working under certain conditions resulting in a ERROR bevy_mod_scripting_core::commands: Lua: Cannot apply callback test command, as script does not exist: test1.lua. Ignoring.:

pub fn trigger_lua_event(
    ctx: FunctionCallContext,
    label: String,
    script_id: String,
) -> Result<(), InteropError> {
    Ok(ctx.world()?.with_global_access(|world| {
        println!("trigger_lua_event {:?} {:?}", label, script_id);

        let command = RunScriptCallback::<LuaScriptingPlugin>::new(
            script_id.into(),
            Entity::from_raw(0),
            label.clone().into(),
            Default::default(),
            false,
        );

        world.commands().queue(command);
    })?)
}
-- this works
function start()
    trigger_event("test", "test1.lua")
end

-- does not work
function start()
    trigger_event("test", "test1.lua")
    local entity = world.spawn()
end

Project that reproduces this: https://github.com/Peepo-Juice/bevy_mod_min_repro

Peepo-Juice avatar Jul 29 '25 12:07 Peepo-Juice

See: https://github.com/bevyengine/bevy/issues/20395#issuecomment-3180870538 for the above, TL;DR the bevy update causes unrelated commands to flush when world entities or components are modified

makspll avatar Aug 13 '25 20:08 makspll