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

DropdownSelect weird behavior #115

Open
Yuri6037 opened this issue Apr 8, 2022 · 9 comments
Open

DropdownSelect weird behavior #115

Yuri6037 opened this issue Apr 8, 2022 · 9 comments

Comments

@Yuri6037
Copy link

Yuri6037 commented Apr 8, 2022

I've added a DropdownSelect to my app with the following code:

                    DropdownSelect::new(vec![
                        ("Light", Theme::Light),
                        ("Dark", Theme::Dark)
                    ]).lens(State::preferences.then(Preferences::theme))

Where State is the application main state, Preferences is an inner struct in State, Theme is an enum with 2 variants (Light and Dark).

Strangely this code works and gives a DropdownSelect where I can select a different item and also updates however when I click on the dropdown itself (to close it, leaving it unchanged) the entire application shuts down like if it crashed but nothing appears in console apart from an exit code of 0. Additionally I can confirm that somehow the widget caused the main rendering/event loop to exit and the main function actually returned...

Is this expected behavior? If it is expected, is there any way to remove this behavior?

@richard-uk1
Copy link
Collaborator

Is the dropdown a subwindow? You could also try turning up the log level to trace to see if you get any more info.

@Yuri6037
Copy link
Author

Is the dropdown a subwindow? You could also try turning up the log level to trace to see if you get any more info.

I don't know if the dropdown is a sub window as I did not program it. However, if you meant whether the dropdown is ON a sub window then yes it is on a sub window.

@richard-uk1
Copy link
Collaborator

Did you manage to get any more info from setting log_level to trace? or is there some code that exhibits this behavior that you can share?

@Yuri6037
Copy link
Author

Yuri6037 commented Apr 11, 2022

Regarding logging it's not easy to enable because in my projects logging is redirected to a custom log backend. Unfortunately druid uses tracing not log and that causes log spamming (apparently druid logs traces in loop when a mouse cursor is on the window under macOS) due to the log level being forced to TRACE itself the result of tracing redirector being broken and ignoring the log level set by log. As a result, in all druid projects I've removed logging because it's completely uncontrollable.

Regarding code, that is more feasible. Let me just try to extract minimal reproducible code for the sub window.

EDIT1: There's actually much worse the example itself is completely broken under macOS!

@Yuri6037
Copy link
Author

Yuri6037 commented Apr 11, 2022

image

This is the result of running select under macOS which uses a DropdownSelect

@richard-uk1
Copy link
Collaborator

This feels like a bug to me, but I'm not sure how to go about reproducing it. I'll see if others have any ideas.

@Yuri6037
Copy link
Author

To reproduce that bug: easy: run the basic select example on macOS Monterey 12.3.1 (Intel) after having forced druid_widget_nursery to latest master druid.

@Yuri6037
Copy link
Author

Yuri6037 commented Apr 11, 2022

About the insta-close problem I've isolated the code in the widget which causes the entire application to terminate:

            ext.submit_command(CLOSE_WINDOW, (), ctx.window_id())
                .unwrap();

File: dropdown_select.rs - line 115-116. By sending CLOSE_WINDOW it basically closes the main window which is handled in my AppDelegate as close the entire application because the application cannot yet handle restarting its main window.

EDIT: Here are the specs of the Mac I've used to reproduce the bugs in case it matters: MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)

@richard-uk1
Copy link
Collaborator

Ah this might be because druid has changed behavior since the widget was made. Anyone know if this is the case?

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

No branches or pull requests

2 participants