-
Notifications
You must be signed in to change notification settings - Fork 930
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
Fix panic when destroying window #2773
Fix panic when destroying window #2773
Conversation
ac99eeb
to
e8233f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I would have thought this to be impossible, since view methods should not be called if the view is no longer attached to a window?
Are you encountering this in multi-threaded code? If so, I suspect that may be the real culprit instead?
Here is a minimum reproducible example: use winit::{
event::{Event, WindowEvent},
event_loop::EventLoop,
window::WindowBuilder,
};
fn main() {
let event_loop = EventLoop::new();
let mut window = WindowBuilder::new()
.with_title("A fantastic window!")
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.build(&event_loop)
.unwrap();
event_loop.run(move |event, target, control_flow| {
control_flow.set_wait();
match event {
Event::WindowEvent {
event: WindowEvent::CloseRequested,
window_id: _,
} => control_flow.set_exit(),
Event::MainEventsCleared => {
window.request_redraw();
window = WindowBuilder::new()
.with_title("A fantastic window!")
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
.build(target)
.unwrap();
}
_ => (),
}
});
} |
e8233f2
to
9f8aba5
Compare
9f8aba5
to
26a2976
Compare
This will need a rebase. ping @madsmtm for re-review |
26a2976
to
60ca3e0
Compare
Done. |
Hmm, I cannot reproduce from your example? Is it still an issue for you? Maybe you can add |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! Now I'm wondering why drawRect:
is being called!
May be part of #2640, since we're handling redraws kinda badly right now?
If you only change drawRect:
to be something like the following, does the issue appear elsewhere?
trace_scope!("drawRect:");
let Some(window) = self._ns_window.load() {
AppState::handle_redraw(window.id());
}
let _: () = unsafe { msg_send![super(self), drawRect: rect] };
And maybe you could enable tracing as well, would be nice for me to see the events you're hitting before the crash.
The issue resolved, so is it a better solution? |
I think I would prefer that, since I suspect it is something that ties in with the fix for #2640. |
60ca3e0
to
31e3606
Compare
Done. |
49126d1
to
01b8d09
Compare
01b8d09
to
dea2f3c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
CHANGELOG.md
if knowledge of this change could be valuable to usersDropping window may cause panic.