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
ResourceLoader can throw NullReferenceException in ProcessResourceFile on the first lookup after PrimaryLanguageOverride changes #26636
After ApplicationLanguages.PrimaryLanguageOverride is set at run time, the next ResourceLoader.GetString reloads all resource tables (EnsureLoadersCultures -> ReloadResources -> ProcessAssembly -> ProcessResourceFile). In our app that first lookup intermittently throws:
System.NullReferenceException
at Windows.ApplicationModel.Resources.ResourceLoader.ProcessResourceFile(...)
at ...ProcessAssembly
at ...ReloadResources
at ...EnsureLoadersCultures
at Windows.ApplicationModel.Resources.ResourceLoader.GetString(...)
at (app code building the new UI)
After a failure the resource tables can stay half-populated: pages built afterwards show a mix of the old and the new language until the app restarts.
Reading src/Uno.WinRT/ApplicationModel/Resources/ResourceLoader.static.cs on release/stable/7.0, the reload is lazy and unlocked (ClearResources, _parsedResources.Clear(), re-parse every .upri), and _loaderContext is only updated at its end. We suspect a concurrent first lookup, but have not instrumented Uno to prove the trigger.
Expected behavior
The first lookup after a language change reloads the tables safely, or the reload happens when the override is set.
How to reproduce it
Set ApplicationLanguages.PrimaryLanguageOverride to another language at run time.
Immediately rebuild UI that calls ResourceLoader.GetString (our case: a shell rebuild right after the language change in Settings).
Roughly 3 of 8 switches (EN <-> ES) failed with the exception above on an Android API 35 emulator, Debug build. No minimal repro yet.
This did not happen with Uno 6.7.18.
Workaround
Make one ResourceLoader.GetString call right after setting PrimaryLanguageOverride, before any UI rebuild, and ignore its failure. With that, 0 failures in more than 10 switches.
Environment
Uno.Sdk 7.0.22, Uno.WinUI 7.0.65, Skia renderer
.NET 10, net10.0-android, Debug, Android API 35 emulator
Activity