-
Notifications
You must be signed in to change notification settings - Fork 666
[wpilib] Support disabling Preferences support for legacy dashboards #8219
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
base: main
Are you sure you want to change the base?
Conversation
4a9ec94
to
fb6fc0a
Compare
Which dashboards does "legacy dashboard" refer to? Can the dashboards be fixed directly if they're still being maintained and that's where the root cause is? |
@calcmogul I'm not sure. The original commit adding this listener (87fc49c) did not provide those details.
The root cause of the SIGSEGV is a race condition in the WPILib C++ code that would be challenging to fix. Dashboards that write to NetworkTables using keys under It's hard to say what dashboards do not do this, as the workaround added ten years ago would hide those bugs. The only way to find them is to turn off the behavior by default at some point. Note the SIGSEGV would not happen in a competition because the default |
If we're going to do something like this, we'd probably prefer it to be opt out, rather then opt in. If you opt out before switching the instance, that should work. Otherwise, this risks breaking dashboards. |
@ThadHouse thanks for the feedback. I considered making it opt-out (by adding a boolean parameter to I didn't consider making it opt-out for the default instance but opt-in otherwise. My initial thinking on that idea is that it would be confusing to users. IMHO the behavior of a Let's see what the WPILib maintainers say about opt-in vs opt-out. If it is opt-out initially, I would personally prefer that it be opt-in for the following year. The APIs to fix the dashboards have existed for a long time, and the SIGSEGV caused a lot of failed GitHub workflows for our team. |
Having it be opt in would be much more confusing for users, and would be a breaking change. A majority of users are not changing the instance. Ideally we'd prefer to fix the actual issue, but pending that having an opt out for users that due run into issues would be enough in our eyes. |
Thanks for the feedback, but I'm not sure if the WPILib team will accept something like this at all, so I won't be making changes on this branch until I get feedback from a maintainer.
If you have ideas on how that might be done, I suggest commenting on the bug. I would personally prefer we fix the underlying issue and have a path forward to eventually removing this work-around. |
@ThadHouse is a WPILib maintainer. |
Ah! Wasn't aware of that. GitHub shows the roles of people making comments on issues, but apparently not in PRs. @ThadHouse sorry for the misunderstanding. I can make changes sometime next week (tracking down and working around this issue in our code ate up a lot time, and I need to focus on other things) @ThadHouse would the WPILib team accept something like this with the listener being enabled by default? |
In 2015, I think the legacy dashboards would have been SmartDashboard, LabVIEW dashboard and SFX (which was dropped long ago). But I think that's less important since any dashboards made after that point could also be depending on that behavior. It does appear that SmartDashboard was updated to set persistent on new keys created in the dashboard. It looks like while Shuffleboard, Elastic, and FRC Web Components have preferences widgets, none of them appear to let users add keys, so wouldn't be affected. However, there are a number of team maintained dashboards that this may break, and this would be a silent breakage, which is bad. One thought would be that it it was opt-out, the listener could also be modified to output a warning if a new key is not set persistent and the listener has to do it, which is a way to warn people about a future change. |
@sciencewhiz I considered that, but since the listeners are triggered from a different thread, it is in theory possible that it would see topics created by the |
fb6fc0a
to
a08829b
Compare
@ThadHouse updated the support for legacy dashboards in this PR to be opt-out. PTAL. |
a08829b
to
b311ab6
Compare
8fae627
to
6206963
Compare
To support legacy dashboards, the Preferences code installed a listener that marked all new topics as persisted. Unfortunately, having a listener that updates new topics in the background can result in a closed NetworkTablesInstance being accessed (resulting in a SIGSEGV) when Preferences.setNetworkTableInstance() is called soon after values have been published for new topics (see wpilibsuite#8215). It's possible this race condition is why PreferencesTest.removeAllTest() was flaky. The code to set new topics discovered under /Preferences as persistent was added back in 2015 in 87fc49c. Dashboards that want to want data for new keys to be saved should be explicitly marking the topics as persistant.
6206963
to
6b3e85b
Compare
To support legacy dashboards, the Java Preferences code installed a listener
that marked all new topics as persisted. Unfortunately, having a listener
that updates new topics in the background can result in a closed
NetworkTablesInstance being accessed (resulting in a SIGSEGV) when
Preferences.setNetworkTableInstance() is called soon after values have been
published for new topics (see #8215).
It's possible this race condition is why PreferencesTest.removeAllTest() was
flaky.
The code to set new topics discovered under /Preferences as persistent was
added back in 2015 in 87fc49c. Dashboards that want to want data for new keys
to be saved should be explicitly marking the topics as persistent.
Note that the listener was only installed in Java, so the original work-
around only worked if the custom dashboard and/or the robot was written in
Java. Custom dashboard used by teams might break today if teams switch from
Java to C++ or Python for their robot code.