-
Notifications
You must be signed in to change notification settings - Fork 104
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
Change ConfigFile
to load after server init
#3731
Conversation
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.
This isn't working:
./miral-test --gtest_filter=TestConfigFile.with_reload_on_change_a_file_in_xdg_config_home_is_reloaded --gtest_repeat=10
Will show around 50% failures
(The patch I shared on MM doesn't do any better)
4b3efd5
to
f6f04ce
Compare
Most cases should fail if a load doesn't happen during the timeout window, but some others should pass if the testcase expects the load to not occur.
Should fix tests crashing due to the test running on one thread and the server on another Co-authored-by: Alan Griffiths <[email protected]>
f6f04ce
to
6a0f1b9
Compare
Replacing |
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.
It all seems reasonable to me, and the tests pass consistently when run locally. However, lxd::ubuntu-24.04:spread/build/ubuntu:ubsan
is failing with init_and_start() timed out
. Maybe increase the timeout?
I now have to wonder: is this actually what we want to do? Before this we were loading a config file immediately and the problem was that we wanted to apply it to objects that don't exist at that time. But another scenario is to want to use configuration values in initialising the program. For that the current behaviour of loading the file immediately is the better timing. Instead of deferring loading the configuration as proposed here, it would be possible, and more flexible, to defer applying the configuration. |
So here's what i think we can do, in addition to the existing |
I think the user can do all that without bothering ConfigFile: they take the data provided by For example, in if (auto const idh = input_device_hub.lock())
{
idh->for_each_mutable_input_device([&m](auto& input_device)
{
m.self->apply_to(input_device);
});
} Currently there is no |
I don't even think we need to fiddle with miral::InputConfiguration input_configuration;
// Share mouse/touchpad/keyboard settings between initial load and reloads
auto mouse = input_configuration.mouse();
auto touchpad = input_configuration.touchpad();
auto keyboard = input_configuration.keyboard();
// Load and try to apply settings immediately, repeat whenever the file changes.
miral::ConfigFile test{runner, "mir_demo_server.input", miral::ConfigFile::Mode::reload_on_change,
[&](auto& in, auto path)
{
// Existing config loading/parsing code
// Apply settings
input_configuration.mouse(mouse);
input_configuration.touchpad(touchpad);
input_configuration.keyboard(keyboard);
}
}};
// Apply settings on compositor startup
runner.add_start_callback(
[&]
{
input_configuration.mouse(mouse);
input_configuration.touchpad(touchpad);
input_configuration.keyboard(keyboard);
});
Seems to do the trick. There's a little duplication but I'm okay with that, what do you think? If you're okay with doing things this way, feel free to close this PR (sorry Harlen :)) |
Well, the duplication does reflect shared requirement, rather than shared implementation. Maybe extract an |
Should allow initial config reads to interact with server components properly.
Also, tweaked tests a bit to be more explicit about failures. More importantly, tests now start the server manually to allow each test's
ConfigFile
instance to be set up. This brings the test behavior closer to the real use case inserver_example.cpp