View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0003765 | NoesisGUI | C++ SDK | public | 2024-10-31 13:35 | 2025-06-03 11:35 |
| Reporter | anton.sodergren_pdx | Assigned To | jsantos | ||
| Priority | normal | Severity | major | ||
| Status | resolved | Resolution | fixed | ||
| Product Version | 3.2.3 | ||||
| Target Version | 3.2.8 | Fixed in Version | 3.2.8 | ||
| Summary | 0003765: Hot reloading of global resources does not work | ||||
| Description | The built-in hot reloading functionality that Noesis has does not seem to work for global resources (ie. resources in the default theme).
Relevant forum thread: | ||||
| Platform | Any | ||||
| related to | 0003853 | resolved | sfernandez | Hot reloading does not work inside TabControl.ContentTemplate |
| related to | 0002704 | resolved | jsantos | RaiseTextureChanged doesn't update image source with relative path |
|
As an extra detail, I can mention that if I'm adding the global resource XAML file to a merged dictionary in a currently visible view, then the file is correctly reloaded. <StackPanel> In this case the style "Style_TextBlock_testingtesting" is stored in AppResources/Fonts.xaml, which is always loaded as a global resource dictionary. When launching the application, both text blocks look correct and can access the style just fine. When I change something in the style (for example text size), and then save the file AppResources/Fonts.xaml, then the second text block (with the merged dictionary) gets updated, but the first text block does not get updated and still has the old text size. |
|
|
The file that we set as our default theme on startup is called "AppResources/_GlobalResources.xaml". That file is a resource dictionary, that contains merged dictionaries that include a bunch of other XAML files (for example "/AppResources/Fonts.xaml"). There's one caveat with this conclusion though. I wrote that we set our default theme to _GlobalResources.xaml, but that is not completely true. What we're actually doing on startup is something like this: const auto RootResourceDictionary = Noesis::MakePtr<Noesis::ResourceDictionary>(); (Config._GenerateResourceDictionary() just creates a resource dictionary and populates it with some resources directly in code.) What's interesting here is that our _GlobalResources.xaml resource dictionary is already a merged dictionary, and yet that one works to hot reload. |
|
|
Also, just for testing, I tried to replace this whole block where we set up our global resources with this: Noesis::GUI::LoadApplicationResources( Noesis::Uri( "AppResources/_GlobalResources.xaml" ) ); Of course this breaks other things for us. But it didn't seem to solve the problem with hot reloading the merged resource dictionaries either. The behavior seemed to be the same. |
|
|
I am doing a few experiments in our HelloWorld C++ sample. Just added the merged dictionary 'Patch.xaml' to App.xaml:
'Patch.xaml' has a color inside:
I am using this color for the background of the window:
With the application launched, I am able to modify this color and the changes are applied correctly. Please, put a break point in the following function in UI.cpp (Gui/Core):
This function is invoked whenever a file is changed and it scans the list of loaded xamls to be reloaded. My theory is that there is some kind of mismatching between the input URI and the one stored in the gLoadedXamls table. Could you please have a look at this? Probably we are missing some kind of normalization for the URI before searching in the hash but I want to confirm first. |
|
|
Thanks for looking into this! I will try debugging this sometime during the week. I don't have local building of Noesis set up currently for stepping through the Noesis code, so I'll have to set that up first. I've also suspected something being off with the URI, but I'm not sure. |
|
|
It’s likely that the URI used for LoadXaml is not exactly the same as the one used in Reload. For example, there might be a mix of backslashes and forward slashes causing the mismatch. This does appear to be a bug on our end, but I’d love to understand more about your specific scenario to investigate further. |
|
|
Correct, I managed to debug this now. The uri that is passed into the function is "AppResources/Fonts.xaml". The key that is stored in gLoadedXamls is "/AppResources/Fonts.xaml", with an extra forward slash in the beginning. |
|
|
In retrospect, this checks out with what we're doing with the uris. In our "AppResources/_GlobalResources.xaml" file, where we reference all our other global resources in a merged resource dictionary, we do use "/AppResources/Fonts.xaml" as uri, like so: |
|
|
At least Blend requires that extra slash to be there, so we can't just remove it. For our user controls on the other hand, when we call Noesis::GUI::LoadComponent, we pass in uris that don't have the slash in the beginning. We could probably change this if we want so we have it standardized, and then we just make sure that the uris passed into RaiseXamlChanged follow the same pattern. |
|
|
Yes, thanks for the detailed information. We need to normalize the URI before doing the comparison. I will work on this ASAP. |
|
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2024-10-31 13:35 | anton.sodergren_pdx | New Issue | |
| 2024-10-31 13:45 | anton.sodergren_pdx | Note Added: 0010088 | |
| 2024-10-31 14:29 | anton.sodergren_pdx | Note Added: 0010090 | |
| 2024-10-31 14:33 | anton.sodergren_pdx | Note Added: 0010091 | |
| 2024-11-05 12:16 | sfernandez | Assigned To | => jsantos |
| 2024-11-05 12:16 | sfernandez | Status | new => assigned |
| 2024-11-05 12:16 | sfernandez | Target Version | => 3.2.6 |
| 2024-11-22 18:18 | jsantos | Target Version | 3.2.6 => 3.2.7 |
| 2024-12-07 17:15 | jsantos | Relationship added | related to 0003853 |
| 2024-12-09 14:39 | jsantos | Note Added: 0010196 | |
| 2024-12-09 14:39 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:39 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:40 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:41 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:41 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:41 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:41 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:42 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:43 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 14:43 | jsantos | Status | assigned => feedback |
| 2024-12-09 14:45 | jsantos | Note Edited: 0010196 | |
| 2024-12-09 17:51 | anton.sodergren_pdx | Note Added: 0010198 | |
| 2024-12-09 17:51 | anton.sodergren_pdx | Status | feedback => assigned |
| 2024-12-09 18:30 | jsantos | Note Added: 0010199 | |
| 2024-12-09 18:30 | jsantos | Status | assigned => feedback |
| 2024-12-12 16:54 | anton.sodergren_pdx | Note Added: 0010220 | |
| 2024-12-12 16:54 | anton.sodergren_pdx | Status | feedback => assigned |
| 2024-12-12 17:02 | anton.sodergren_pdx | Note Added: 0010221 | |
| 2024-12-12 17:13 | anton.sodergren_pdx | Note Added: 0010222 | |
| 2024-12-12 17:21 | jsantos | Note Added: 0010223 | |
| 2025-01-20 17:42 | jsantos | Target Version | 3.2.7 => 3.2.8 |
| 2025-05-28 10:51 | jsantos | Note Edited: 0010196 | |
| 2025-05-28 10:55 | jsantos | Note Edited: 0010196 | |
| 2025-05-28 12:26 | jsantos | Status | assigned => resolved |
| 2025-05-28 12:26 | jsantos | Resolution | open => fixed |
| 2025-05-28 12:26 | jsantos | Fixed in Version | => 3.2.8 |
| 2025-06-03 11:35 | jsantos | Relationship added | related to 0002704 |