-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The ability to create fake windows #3754
Comments
#3439 implemented a headless mode. |
Unfortunately no. I only made it work without renderer in that PR. But there is no "headless window" for now. |
I am looking at implementing this, and was wondering: in bevy_render, the bevy/crates/bevy_render/src/lib.rs Line 127 in 44d09dc
When a window doesn't have a handle, we need to skip at least the bits of the RenderPlugin that rely on the handle for information. However, it could mean that resources and such are missing that other components rely on. What is your opinion on this? I'm at this point not all to familiar with the rendering side of things to know how much I can "cut out" when there is no window without strange behavior occurring. |
I think it should work with |
It turned out I didn't even need to skip any of the RenderPlugin code, as the I can now run an app in a test with almost all of the Being able to do Is there a way to skip the WinitPlugin (without setting the feature flag)? Or would it be better to add an option to the plugin to allow running in a separate thread? |
You can use something like
On some platforms the OS requires that the event loop runs on the main thread. |
Awesome!
Sure can: bevy/examples/app/without_winit.rs Line 6 in 44d09dc
Running DefaultPlugins as is (e.g. with WinitPlugin ) doesn't make sense, you don't want to create actual window in each test.
P.S.: for unit tests I would recommend to setup minimal set of plugins for each module (here is how I set things up, for example). |
Solved by ddfafab. |
What problem does this solve or what need does it fill?
When writing unit tests for the UI, access to the window is required. But since the tests run in parallel by default, it's impossible to create a real window outside of the main thread. For details, see #1720.
What solution would you like?
But for unit testing, a real window is not needed, it is enough to create a fake one. Currently users can add windows manually using add on
Windows
resource and pass aWindow
struct to it. But to create aWindow
I need to provide RawWindowHandle. I would suggest to turn this field intoOption
. This way users will be able to create dummy windows and UI plugins will know necessary stuff, like window size and scale. Currently UI plugins such as Egui work in headless mode, but crashes on any access to context because there is no associated window.The text was updated successfully, but these errors were encountered: