Skip to content
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

Update Winit and Fix crash on x11 Linux #481

Closed
wants to merge 4 commits into from
Closed

Update Winit and Fix crash on x11 Linux #481

wants to merge 4 commits into from

Conversation

hYdos
Copy link

@hYdos hYdos commented Oct 14, 2021

Fixes thread 'main' panicked at 'attempted to leave type platform::platform::x11::util::input::PointerState uninitialized, which is invalid', /rustc/c8dfcfe046a7680554bf4eb612bad840e7631c4b/library/core/src/mem/mod.rs:663:9 on X11 Linux devices.

TODO:

  • Fix Triangle Example
  • Fix Texture Example

ash-window/examples/winit.rs Outdated Show resolved Hide resolved
hYdos and others added 3 commits October 14, 2021 17:07
Because Winit has changed quite a bit since 0.19, some of the test lifecycle had to change.

Explanation of the changes:
1) `EventLoop::run` is the new way of starting the event loop. This function will never return. There is `EventLoop::run_return` but that does not exist on macOS, so let's use `EventLoop::run` so all platforms may use the same code.
2) Since the callback winit takes is 'static and I need to process some destructor code, the `ExampleBase::run` function now takes a state object, of type `T`. The state object may be accessed while rendering and when the application is exiting, allowing destruction of Vulkan state.
3) Invocation of the rendering function needs to occur in `RedrawRequested`and we request a redraw always after rendering.
4) Eliminate the `RefCel`l around the event loop by having the event loop outlive the entire application. This means `ExampleBase::new`'s function signature now returns `(EventLoop<()>, Self)`

The code appears to run properly after testing.
@i509VCB
Copy link
Contributor

i509VCB commented Oct 16, 2021

I've helped out @hYdos here with this since he does not understand winit too well. Winit changes have meant some of the example code had to change.

I have detailed why I've changed the code to be how it is in my commit for a35b98b.

event: winit::event::WindowEvent::Destroyed,
..
} => {
surface_fn.destroy_surface(surface, None);
Copy link
Contributor

@i509VCB i509VCB Oct 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hydos this is wrong, needs to be moved to the winit::event::Event::LoopDestroyed branch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait I can't read. Ignore me

@MarijnS95
Copy link
Collaborator

Keep in mind that #356 also performs this upgrade, and improves the examples at the same time.

@i509VCB
Copy link
Contributor

i509VCB commented Oct 16, 2021

Hmm yeah I think waiting for #356 is better.

Doing the update didn't cost me much time anyways.

@hYdos
Copy link
Author

hYdos commented Oct 16, 2021

Ill close this one for now, When is that one getting merged? It looks like it hasn't been touched since 27 feb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants