bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.28k stars 3.58k forks source link

`bevy_render` should not depend on `bevy_winit` #15565

Closed alice-i-cecile closed 1 month ago

alice-i-cecile commented 1 month ago

Problem

14284 added a direct, non-optional dependency on bevy_winit from bevy_render.

This is messy for our crate structure, and makes it much harder to use bevy_render on exotic platforms.

It's also causing issues for contributors:

I'm having issues running tests locally on main. Trying tests like (e.g. cargo test --package bevy_ui --lib layout::ui_surface::tests) I'm getting The platform you're compiling for is not supported by winit

From @StrikeForceZero on Discord.

Proposed solution: revert the cursor icon PR.

Revert #14284 and reopen #14351.

Solves this problem very directly, at the expense of a valuable feature. Back to the drawing board, where none of the options seemed very good.

Proposed solution: make the dependency optional by feature-flagging cursor icons

Still messy, but something that can be worked around. Doesn't lose us the nice feature.

Proposed solution: bevy_cursors crate

Lift this code out into its own crate, which depends on bevy_winit and bevy_render. Probably the cleanest conceptually, but now we have yet another tiny crate to maintain.

alice-i-cecile commented 1 month ago

I'm personally okay with any of these solutions, but a bevy_cursors crate is my favorite, followed by the feature flagging approach.

BenjaminBrienen commented 1 month ago

I like the bevy_cursors idea. It's a crate that solves a specific problem and it helps keep the other crates focused on solving their specific problems.

mockersf commented 1 month ago

Creating a crate just for cursors feels a bit pointless and like bloat.

I would prefer to move the ANDROID_APP declaration out of bevy_winit. It would make sense to have it in bevy_window for example. that would let us break the dependency between bevy_winit and bevy_asset, and open the possibility to change the direction of dependencies with bevy_render

alice-i-cecile commented 1 month ago

I'm on board with that plan.

KirmesBude commented 1 month ago

Seems like reversing the dependency is not really desirable either. I can see at least one more use for a bevy_window_extensions crate (something like that, instead of bevy_cursors), which is window icons. Not sure if there is more.