Repository navigation
fix(storage): Merge settings writes across instances - #25715
Merged
ramezgerges merged 1 commit intoOct 27, 2026
Merged
ramezgerges merged 1 commit into
ramezgerges merged 1 commit into
Conversation
On Skia desktop, ApplicationData settings were read once per process and every write saved that whole copy back. Two instances of the same app therefore undid each other: keys the other one added were lost and keys it removed came back. A failed read left an empty copy whose next write erased the file, and writes went over the file in place. The settings file is now shared safely: - each change takes an exclusive lock (flock on Unix, sharing modes on Windows), re-reads the file, applies just that key and replaces the file atomically; readers take a shared lock, since Windows can't replace a file another process has open; - reads pick up changes other instances made, re-reading a file written within the last 2 s because coarse file systems can repeat its stamp; - a change that can't be saved (lock timeout, unreadable file) stays pending: it remains visible and is saved with the next write; - a damaged file is moved aside and rebuilt from the last good copy, a short read is retried first, and only a missing file counts as empty; - a change that makes no difference doesn't rewrite the file. Enumerating the container also returned the serialized strings instead of the values, and setting a key to null wrote the file twice. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Contributor
|
The build 241465 found UI Test snapshots differences: Details
|
ajpinedam
approved these changes
Oct 26, 2026
Contributor
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
2 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GitHub Issue: closes unoplatform/uno-private#2472
PR Type:
🐞 Bugfix
What changed? 🚀
The bug: on Skia desktop (Windows, macOS, Linux),
ApplicationData.Current.LocalSettingsandRoamingSettingswere read from disk once per process, and every write saved that whole in-memory copy back. When two instances of the same app ran at once, the last writer won:Two related problems in the same code:
File.OpenWriteoverwrote the file in place, so a crash part-way through left a broken file.The fix: the store moves into a new internal
SettingsFileclass (src/Uno.WinRT/Storage/Internal/SettingsFile.skia.cs):.lockfile, re-reads the file, applies only that key change, writes a temporary file and atomically replaces the settings file. The lock isflockon Unix and file sharing modes on Windows, both throughFileShare..corruptand rebuilt from the last good copy.Two smaller bugs in
FilePropertySetare fixed as well:nullwrote the file twice.The on-disk format is unchanged, so files written by earlier versions are read as before.
Limits (documented on the class): the locks are advisory. They do nothing if an app turns off .NET file locking (
System.IO.DisableFileLocking), or on a network file system that ignoresflock.Validation
Given_SettingsFile, 16 tests. TwoSettingsFileinstances on one file stand in for two processes. All 39Windows_Storageunit tests pass.PR Checklist ✅
Given_SettingsFile.Screenshots Compare Test Runresults.🤖 Generated with Claude Code