feat(bevy_matchbox): port to Bevy 0.19 and move the workspace to ggrs 0.13 - #557
Open
AdamWhitehurst wants to merge 3 commits into
Open
feat(bevy_matchbox): port to Bevy 0.19 and move the workspace to ggrs 0.13#557AdamWhitehurst wants to merge 3 commits into
AdamWhitehurst wants to merge 3 commits into
Conversation
`Resource` is now a subtrait of `Component`, so the `Component` derive on `MatchboxSocket` is a conflicting impl and goes. `Command` gained an associated output type, so `OpenSocket`, `CloseSocket`, `StartServer` and `StopServer` each declare `type Out = ()`. Both background tasks stay owned fields. Dropping a task cancels it on every target under 0.19, which is what makes `close_socket` and `stop_server` stop the work they name. A test holds that invariant. It builds a socket over a message loop that trips a flag when dropped, removes the resource, and waits for the flag. The doc examples drop the component pattern the migration guide calls out, and `new_unreliable` and `new_reliable` insert the socket as a resource.
`matchbox_socket` takes ggrs `^0.13`, which its source already satisfies. `examples/bevy_ggrs` is what forces the floor. On Bevy 0.19 it needs `bevy_ggrs` 0.22, which requires ggrs `^0.13`, and `^0.11` will not unify with it. `cargo tree -i ggrs` reports one version. The example moves with both bumps. A rollback entity takes a `Rollback` component, `with_num_players` returns a `Result`, and `TextFont` names its font and size through `FontSource` and `FontSize`. The five published crates go to 0.15.0, which is what upstream's own Bevy 0.19 pull request intends to publish, so this branch stays rebasable onto it. A workspace lint table allows `result_large_err` and `collapsible_match`. Both predate the lints that report them, in crates this branch changes only the manifests of.
The table is the crate's own documentation through `include_str!`, so a reader on docs.rs sees which release targets which Bevy.
Closed
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports
bevy_matchboxto Bevy 0.19 and moves the workspace to ggrs 0.13. Onlybevy_matchboxdepends on Bevy, so the Bevy surface is three source files; the ggrs floor moves becauseexamples/bevy_ggrsneedsbevy_ggrs0.22 on Bevy 0.19, and that requires ggrs^0.13. The five published crates go to 0.15.0.Why
bevy_matchbox0.14 targets Bevy 0.18 and there is no 0.19 release, so it is what holds a Bevy 0.19 project on 0.18.Changes
MatchboxSocketdrops itsComponentderive.Resourceis nowpub trait Resource: Component, so deriving both is a conflicting impl.OpenSocket,CloseSocket,StartServerandStopServereach declaretype Out = (), whichCommandgained.MatchboxSocketkeepsBox<dyn Debug + Send + Sync>andMatchboxServerkeepsTask<Result<(), Error>>, because dropping a task cancels it and that is what makesclose_socketandstop_serverstop the work they name. Bevy 0.19 re-exportsasync_task::Taskdirectly, so this now holds on web as well as native.bevy_matchbox/src/socket.rsgainsclosing_the_socket_cancels_its_message_loop, which builds a socket over a message loop that trips a flag when dropped, removes the resource, and waits for the flag. It fails if the task is detached.new_unreliableandnew_reliableinsert the socket as a resource, and the type-level "As a Component" example goes. They still compiled, sinceResourceimpliesComponent, which is why the compiler did not catch them.matchbox_sockettakes ggrs^0.13in both dependency tables. The source needs no change, sinceimpl NonBlockingSocket<PeerId> for WebRtcChannelstill matches the trait.examples/bevy_ggrstakesbevy0.19 andbevy_ggrs0.22. A rollback entity takes aRollbackcomponent,with_num_playersreturns aResult, andTextFontnames its font and size throughFontSourceandFontSize.result_large_errandcollapsible_match. Both predate the lints that report them. Rejecting a websocket upgrade returns an axumResponse, and boxing it would change a public callback signature.README.mdgains the0.19 | 0.15, maincompatibility row.Before / After
matchbox_socket^0.11^0.13bevy_ggrs, in the exampleMatchboxSocketResourceandComponentResourceVerification
cargo test --features signaling --all-targets,cargo test --docandcargo clippy --features signaling --all-targets -- -D warningspass on stable 1.97.1, along with the wasm check overmatchbox_socket,bevy_matchbox,bevy_ggrs_example,simple_exampleandcustom_signaller.cargo tree -i ggrsreports one version.hello_hostandhellowere run against each other. The host logs a connected peer and both processes exchange their periodic messages, so data channels open onIoTaskPoolwith no tokio runtime. A downstream project also connects two peers over its own signaller with this branch as a path dependency.Relationship to #556
#556 covers the same Bevy 0.19 migration and this branch was written against upstream
maininstead of taken from it, so the two differ where it made different calls. #556 detaches both background tasks, which is what the owned-task test here asserts against, and dropsMatchboxSocket's second field. It also moves the native message loop onto a dedicated tokio runtime because data channels never open with webrtc-rs 0.17; that symptom did not reproduce here, so this branch leaves the loop onIoTaskPool. Happy to fold either way if the maintainers prefer #556's shape.