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

Application stuck when closing the window #2532

Closed
4 tasks done
brcha opened this issue Jul 29, 2024 · 16 comments
Closed
4 tasks done

Application stuck when closing the window #2532

brcha opened this issue Jul 29, 2024 · 16 comments
Labels
bug Something isn't working shell
Milestone

Comments

@brcha
Copy link

brcha commented Jul 29, 2024

Is your issue REALLY a bug?

  • My issue is indeed a bug!
  • I am not crazy! I will not fill out this form just to ask a question or request a feature. Pinky promise.

Is there an existing issue for this?

  • I have searched the existing issues.

Is this issue related to iced?

  • My hardware is compatible and my graphics drivers are up-to-date.

What happened?

I am evaluating the library and I've tried the counter example. When I close the window by clicking on the close button, the application never ends, it just stays running in the background until I kill it manually (Ctrl+C in the terminal). I've added printlns around the iced::application call, and indeed, the "after" println never happens. Here's a screenshot to illustrate that. On the latest release (0.12.1) application terminates normally when the window is closed.

image

What is the expected behavior?

I would expect the application to terminate when the window is closed.

Version

master

Operating System

Linux

Do you have any log output?

No response

@brcha brcha added the bug Something isn't working label Jul 29, 2024
@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

Are you sure a5b1a1d doesn't fix the issue?

@brcha
Copy link
Author

brcha commented Jul 29, 2024

I have iced.git = "https://github.com/iced-rs/iced.git" in Cargo.toml, and this commit has been merged. I was building outside of iced's source, so now I've checked out latest iced from git and built the example from there, and it still stalls when the window is closed. So, no, it doesn't fix the issue.

@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

Interesting. I can't reproduce, but I wonder if this may have to do with the Drop order of our Window instances in the window_manager module.

Could you try 6948c65?

@brcha
Copy link
Author

brcha commented Jul 29, 2024

I've just tried that. It didn't help…

@brcha
Copy link
Author

brcha commented Jul 29, 2024

I've added if window_manager.is_empty { break 'main } from v0.12 to your fix branch and now closing the window works.

image

@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

That is not a proper fix, since the application may need to exit even without a close request.

I believe you are not getting Destroyed window events for some reason. Try adding in line 930:

dbg!(&window_event);

@brcha
Copy link
Author

brcha commented Jul 29, 2024

I've added dbg at the start of the WindowEvent match and I do get the Destroyed event, but then the app continues getting keyboard events forever. Here's the output from the terminal (on the second run, when I promptly ctrl+c-ed it):

[winit/src/program.rs:924:25] &window_event = CloseRequested
[winit/src/program.rs:924:25] &window_event = Destroyed
[winit/src/program.rs:924:25] &window_event = ModifiersChanged(
    Modifiers {
        state: ModifiersState(
            CONTROL,
        ),
        pressed_mods: ModifiersKeys(
            0x0,
        ),
    },
)
^C

@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

You should be getting 2 destroyed events. One at the very beginning.

@brcha
Copy link
Author

brcha commented Jul 29, 2024

I've moved boot_window_closed = true to before the if and it closes correctly. That clearly isn't the fix either if I should get two destroyed events :)

@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

I imagine the boot window we use to initialize the Compositor may not be producing a Destroyed event in some platforms.

  • Are you on Wayland?
  • Does ce539c3 fix the issue?

@brcha
Copy link
Author

brcha commented Jul 29, 2024

Nope, I'm on X11. But that change does fix the issue.

@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

Well, then we know it's a winit bug for sure.

@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

I think c6d1a0e works around the bug without keeping a ghost window around and also should avoid prematurely exiting applications when a window is in the process of being opened.

Could you confirm it works?

@brcha
Copy link
Author

brcha commented Jul 29, 2024

Yes, it does work excellently. I also have a Mac and Windows machines, I could check if this change does break something on other systems, if you want.

@hecrj hecrj closed this as completed in 10f367a Jul 29, 2024
@hecrj
Copy link
Member

hecrj commented Jul 29, 2024

@brcha I have access to those platforms too. I don't see why it would break anything, however.

Thanks for the testing!

@hecrj hecrj added this to the 0.13 milestone Jul 29, 2024
@hecrj hecrj added the shell label Jul 29, 2024
@brcha
Copy link
Author

brcha commented Jul 29, 2024

You are welcome :) Excellent lib, I am really excited for an Elm style UI in Rust.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working shell
Projects
None yet
Development

No branches or pull requests

2 participants