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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registry settings cannot be read or get deleted #2438

Closed
jonathanlinat opened this issue Nov 5, 2018 · 16 comments 路 Fixed by #2447
Closed

Registry settings cannot be read or get deleted #2438

jonathanlinat opened this issue Nov 5, 2018 · 16 comments 路 Fixed by #2447
Assignees
Labels
Prio:1 Highest priority: Crash or crippling bugs, features that enable new ways of working Type:Bug Errors and problems
Milestone

Comments

@jonathanlinat
Copy link
Contributor

jonathanlinat commented Nov 5, 2018

System Information

TrenchBroom V2.1.0-RC2 on Windows 10

  1. Fresh installation. Opened TB and a custom personal map. All OK. 馃憤
  2. Reset to defaults in each of the View panels, and applied new default settings.
  3. Closed and opened TB. Entities are not shown.

image

  1. Closed and opened TB. Entities are shown but... error 87

image

  1. Closed and opened. All OK. 馃憤
@muk0r
Copy link

muk0r commented Nov 5, 2018

I received a similar error.
image

Id guess these errors are related to my loss of preferences I reported in Discord.

@kduske kduske added OS:Win Prio:1 Highest priority: Crash or crippling bugs, features that enable new ways of working Type:Bug Errors and problems labels Nov 5, 2018
@kduske kduske added this to the 2.1.0 milestone Nov 5, 2018
@kduske kduske changed the title Can't create registry key 'HKCU\Software\Kristian Duske\TrenchBroom\Controls\Camera' (error 87: The parameter is incorrect.) Registry settings cannot be read or get deleted Nov 5, 2018
@kduske
Copy link
Collaborator

kduske commented Nov 5, 2018

Ok. This Camera key error is triggered modifying the FOV value from the View panel.

@kduske
Copy link
Collaborator

kduske commented Nov 5, 2018

Fresh RC2 installation. Opened up a new map. Opened View panel. Changed FOV value to 100. Applied. Closed window. Saved map. Closed TB. Opened TB and then error 87.

System language is en_us. Well possible that it's an issue with how floats are serialized (converted to strings and unconverted).

@jonathanlinat
Copy link
Contributor Author

@kduske
Copy link
Collaborator

kduske commented Nov 5, 2018

@jonathanlinat
Copy link
Contributor Author

Error 6

2018-11-05_18-15-11

@jonathanlinat
Copy link
Contributor Author

jonathanlinat commented Nov 6, 2018

Build gad2e770

Crashed too.

image

tb-v210rc2-gad2e770-error6.zip

@jonathanlinat
Copy link
Contributor Author

jonathanlinat commented Nov 6, 2018

Build gad2e770

Something really weird.

  1. Fresh installation. No registry. Opened TB for the first time and closed it. This is the result:

image

  1. Deleted previous registry. Fresh installation. Opened TB for the second time and closed it. This is the result:

image

The tree is different, for the same exact behavior.

@jonathanlinat
Copy link
Contributor Author

jonathanlinat commented Nov 6, 2018

Build g4a2f915

  1. No previous registry. Fresh install. First launch.

image

  1. Deleted previous registry. Fresh install. Second launch.

image

So, no more weird tree. I'll try to modify settings now.

  1. Deleted previous registry. Fresh install. First launch. Opened Preferences. Applied a FOV of 110. Closed TB.

image

I'll keep this registry and try to modify the FOV value again.

  1. Previous registry NOT deleted. Fresh install. Other launch. Opened Preferences.

image

FOV value in TrenchBroom preferences differs from the registered value in Registry.

  1. Closed previous TB instance. Previous registry NOT deleted. Fresh install. Other launch. Opened Preferences.

image

FOV value in TrenchBroom preferences is now well retrieved from the Registry. 馃

@jonathanlinat
Copy link
Contributor Author

jonathanlinat commented Nov 6, 2018

馃憤

So yeah, at this moment, no more error 6 reported. Last commit seems to have fixed the issue.

But, sometimes FOV value in Preferences differs from the registered one present into Registry.

@jonathanlinat
Copy link
Contributor Author

jonathanlinat commented Nov 6, 2018

Build g4a2f915

Two attempts. Actions between Reset to defaults, Ok, Apply, closing the app, opening it.

  1. First attempt. error 0

2018-11-06_20-14-03

  1. Second attempt. Value from Registry not retrieved + error 0

2018-11-06_20-19-35

@ericwa
Copy link
Collaborator

ericwa commented Nov 8, 2018

I'm convinced it's a wxWidgets bug, or at least the registry access is failing inside wxWidgets somehow. I made a branch where all config access is via absolute paths, and I still get this error on commit 40578eb (it's random but happens on around 40% of launches. Seems to happen only when a Release build exe is launched via double clicking the .exe in Windows Explorer).

error2

This reproduces @jonathanlinat 's last post. I verified that we're calling the wxConfig API with "\TrenchBroom\Controls\Camera\Field of vision" and that key exists in the registry, but the error shows that there was an attempt to access "\TrenchBroom\Field of vision" for some reason.

wxRegConfig::DoReadString uses wxConfigPathChanger internally so maybe that fails which leads to accessing the wrong path?
https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/regconf.cpp#L560

All I can think of now is stop using the wx registry code. I still have no idea what changed between RC1 and RC2 that caused this, and I've had no luck debugging it because i can only reproduce it in Release builds :-/

@kduske
Copy link
Collaborator

kduske commented Nov 8, 2018

Maybe if we rename that key to "FOV" it will help? But I'd rather switch to a file based config at this point.

@kduske
Copy link
Collaborator

kduske commented Nov 8, 2018

Oh and while we're destroying people's preferences, we should also switch to writing / reading typed values instead of serializing / deserializing with strings.

@ericwa
Copy link
Collaborator

ericwa commented Nov 8, 2018

I posted on discord but it turns out the fly mode thread is accessing preferences from a background thread which is probably breaking everything. Call stack looks like:

0116233D (TrenchBroom): (filename not available): TrenchBroom::Preference<float>::load
01240A1A (TrenchBroom): (filename not available): TrenchBroom::View::FlyModeHelper::moveDelta
012406DB (TrenchBroom): (filename not available): TrenchBroom::View::FlyModeHelper::Entry

Oh and while we're destroying people's preferences, we should also switch to writing / reading typed values instead of serializing / deserializing with strings.

Yes, if we switch to JSON this would make sense. If we stick with the INI format that wxFileConfig uses, it doesn't make a difference, since INI doesn't distinguish strings from numbers.

For 2.1.0 I suggest we stick with the registry, get rid of any preference accesses from background threads, stick ensure(wxThread::IsMain(), "called on non-main thread"); anywhere that accesses wxConfig.

@kduske
Copy link
Collaborator

kduske commented Nov 8, 2018

Aha, good find! So we need to synchronize access from the fly mode thread, or rewrite fly mode as we discussed to processing events on the main thread. I vote for the latter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Prio:1 Highest priority: Crash or crippling bugs, features that enable new ways of working Type:Bug Errors and problems
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants