AutoDarkMode / AutoDarkMode/Windows-Auto-Night-Mode

Internal: Performance issues

Open
#962 4 comments 1 reaction 0 assignees View on GitHub
area-internal framework
Dominant language
C#
Stars
9.7k
Forks
308
Avg merge
2d 58m
Merged PRs (30d)
3

Description

### Time/Location service

You might have seen that there can be a performance issue with the loading of the Time settings when using slow internet. This is because `LoadGeolocationData` can take quite some time. On slow wifi, it may take many (more than ten!) seconds to fill/update the "location" text box. At the moment, `TimeViewModel` contains `LoadSettings` and just a few lines later `HandleConfigUpdate`, and the last one also calls `LoadSettings` again. This all means that `LoadGeolocationData()` is called very often: every Page load and every change in the Radio buttons!

But when you think about it - a physical location is not expected to change ~much~ in this period, and the Geo Coordinates are "manual" input by definition. That's why I've already suggested to cache the data for quick UI load. And then move the bits that do the actual "retrieve", to app/window load event.

### Saving and reading settings (broad scope)

- `SaveConfig` seems to be very inefficient. Calling `File.Open` with a **FileMode.Create** flag results in a new file being created every single time!
- Every `_dispatcherQueue.TryEnqueue` block, for the builder settings, looks extremely redundant to me. There **must** be a better way.
```cs
_dispatcherQueue.TryEnqueue(() =>
{
_builder.Load();
LoadSettings();
});
```
- Have we thought about JSON?

### investigate: Dialogs and Hyperlinks.

Prefer to use it the "normal" way.

### check: changing UI language

### async builder

Should
```cs
_builder.Save();
```
be...?
```cs
await _builder.SaveAsync(); // Ensure Save is awaited
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing TimeViewModel.LoadSettings, HandleConfigUpdate, and LoadGeolocationData, then inspect SaveConfig, the _dispatcherQueue.TryEnqueue blocks, and the builder Save/SaveAsync entry points. The issue contains several broad investigations rather than a single completion condition; done would require narrowing and agreeing on the scope, then validating the selected performance and async changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.