You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove uses of opts::get() from as much code as possible #22854
Right now the code in components/config has a bunch of code depending on it because the command line arguments for Servo are global singleton that any code can access. This makes changing the command line code for Servo frustrating, because a lot of code gets rebuilt unnecessarily. We should remove as many uses of opts::get() as possible, and replace them with values that are passed into appropriate constructors via the code in components/servo/lib.rs.
I'm not sure I understand what you're suggesting. Do you have an example?
I am suggesting that all CLI arguments would actually set a preference, which would not be persisted. Instead of accessing opts, any configurable code would just access prefs. The actual value would be evaluated in ascending order of precedence: prefs.json, user preferences, CLI argument.
For example, tile_size is currently a CLI argument but not in preferences. It could be made into a preference which would allow you to set it via prefs.json or choose to override it via CLI. This mechanism already works as part of my Preferences PR, and several CLI arguments are propagated that way, e.g. layout threads.
Ah, I see. The advantage of keeping the command line arguments separate from preferences is that the arguments are not mutable. This is one reason why it's safe to remove access to the global arguments storage and pass the values directly to the code that uses them, allowing us to remove dependencies.
@jdm It's not ideal then that some opts are actually duplicated as (mutable) prefs, so you could get a different value for layout.threads, depending on if you access it via opts or prefs.
Rather than replace all instances of opts with dependency injection, another approach is to split opts into two levels: globals (which should change infrequently) and crate-level options (which can develop alongside the features of the crate itself). For example, bluetooth only uses one option: headless, which is global. compositing uses some globals (exit_after_load maybe?), but also more specific options like device_pixels_per_px.
Each crate would define its own options and provide access to both its own and the global options.
If you add or remove a global option then all the component crates will still need to be rebuilt, but adding a compositing option won't affect bluetooth.
You say headless is global, but it's only used by 3 crates (or 5 modules). I guess I don't see a big benefit to continuing to expose a set of global options, given how restricted their use generally is.
That's a good idea! It would be an improvement over the status quo because the use of opts::get would stop, and it would be a global that's private to a particular crate.
Activity
highfive commentedon Feb 8, 2019
Hi! If you have any questions regarding this issue, feel free to make a comment here, or ask it in the
#servochannel in IRC.If you intend to work on this issue, then add
@highfive: assign meto your comment, and I'll assign this to you. 😄snowsignal commentedon Feb 21, 2019
@highfive: assign me
highfive commentedon Feb 21, 2019
Hey @JacksonCoder! Thanks for your interest in working on this issue. It's now assigned to you!
peterjoel commentedon Mar 6, 2019
Couldn't
optsjust be a non-persistentprefsoverride? Or will this just move the same problem?jdm commentedon Mar 6, 2019
I'm not sure I understand what you're suggesting. Do you have an example?
peterjoel commentedon Mar 6, 2019
I am suggesting that all CLI arguments would actually set a preference, which would not be persisted. Instead of accessing
opts, any configurable code would just accessprefs. The actual value would be evaluated in ascending order of precedence:prefs.json, user preferences, CLI argument.For example,
tile_sizeis currently a CLI argument but not in preferences. It could be made into a preference which would allow you to set it viaprefs.jsonor choose to override it via CLI. This mechanism already works as part of my Preferences PR, and several CLI arguments are propagated that way, e.g. layout threads.jdm commentedon Mar 6, 2019
Ah, I see. The advantage of keeping the command line arguments separate from preferences is that the arguments are not mutable. This is one reason why it's safe to remove access to the global arguments storage and pass the values directly to the code that uses them, allowing us to remove dependencies.
peterjoel commentedon Mar 6, 2019
@jdm It's not ideal then that some opts are actually duplicated as (mutable) prefs, so you could get a different value for
layout.threads, depending on if you access it viaoptsorprefs.jdm commentedon Mar 6, 2019
That's true! Anything that is duplicated should be removed from the immutable options structure and any users changed to use the preference.
jdm commentedon Mar 6, 2019
With the caveat that using the command line option should mutate the preference.
peterjoel commentedon Mar 6, 2019
Rather than replace all instances of
optswith dependency injection, another approach is to split opts into two levels: globals (which should change infrequently) and crate-level options (which can develop alongside the features of the crate itself). For example,bluetoothonly uses one option:headless, which is global.compositinguses some globals (exit_after_loadmaybe?), but also more specific options likedevice_pixels_per_px.Each crate would define its own options and provide access to both its own and the global options.
If you add or remove a global option then all the component crates will still need to be rebuilt, but adding a compositing option won't affect bluetooth.
jdm commentedon Mar 6, 2019
You say headless is global, but it's only used by 3 crates (or 5 modules). I guess I don't see a big benefit to continuing to expose a set of global options, given how restricted their use generally is.
42 remaining items
jdm commentedon Oct 11, 2019
That's a good idea! It would be an improvement over the status quo because the use of opts::get would stop, and it would be a global that's private to a particular crate.
Remove usage of opts::get() from style::context.
Remove usage of opts::get() from style::context.
Remove usage of opts::get() from style::context.
Remove usage of opts::get() from style::context.
Auto merge of #24500 - kitlith:style_cfg, r=emilio
Remove usage of opts::get() from style.
Auto merge of #24500 - kitlith:style_cfg, r=emilio
Remove usage of opts::get() from style.
Auto merge of #24500 - kitlith:style_cfg, r=jdm
JMarlin commentedon Mar 4, 2020
@highfive: assign me
highfive commentedon Mar 4, 2020
Hey @JMarlin! Thanks for your interest in working on this issue. It's now assigned to you!