Gigas002 / GTiff2Tiles

Analogue of gdal2tiles.py/MapTiler on C#.
https://gigas002.github.io/GTiff2Tiles/
Do What The F*ck You Want To Public License
15 stars 4 forks source link

[bug] InvalidOperationException at end of lengthy processing session. #224

Closed ShammyLevva closed 1 year ago

ShammyLevva commented 1 year ago

Describe the bug Ran to 98% and errored on line 788 of MainViewModel

Line 788 is await DialogHost.Show(new MessageBoxDialogViewModel(Strings.Done)).ConfigureAwait(true);

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Private.CoreLib.dll No loaded DialogHost have an Identifier property matching dialogIdentifier ('') argument.

To Reproduce I have a geotiff that it fails on but it takes some 3 hours to process and fails just as it's getting close to finishing.

Input data info data is some 9Gb in size I think it's less about the geotiff file itself and some bug in the I'm finishing up code. I can provide the file if required. I'd need to provide a private communication to provide a download link rather than posting a public link to github.

Expected behavior I'd expect when it reaches 100% it gracefully completes.

Desktop: Windows 11 patched up to Patches issued on Patch Tuesday 9th May 2023.

I'm using VS 2022 v17.5.5 using code built as of Merge pull request https://github.com/Gigas002/GTiff2Tiles/pull/216 from Gigas002/dependabot/nuget/MaxRev.Gdal.Wi… on May 10th 2023. building from source.

In case it's relevant I was running the GUI version.

Gigas002 commented 1 year ago

Hello. If possible, would you mind testing the build from latest commit with any tiff from Examples directory? The error looks like a GUI only, so it's possible, that latest PR's (related to MaterialDesign stuff) fixed the error. I, unfortunately, doesn't own a windows machine right now, and no longer contribute to this project with exception for dependabot alerts, but I'll try to help you with the issue as much as I can.

If the error persists, you can try running the CLI version instead. Judging by ci runs it should work fine.

ShammyLevva commented 1 year ago

It does appear to be GUI only indeed now I've looked at the code in the cold light of day (aka after sleeping). I can see that the line I referenced is actually simply a "Done" message box. I've not done any wpf coding before so not familiar with the need for the async calling for displaying a static message box. If the async isn't required then the code simplifies from await DialogHost.Show(new MessageBoxDialogViewModel(Strings.Done)).ConfigureAwait(true); to MessageBox.Show(Strings.Done);

Gigas002 commented 1 year ago

async is important to not block a GUI thread, and there's no MessageBox class from WinForms in WPF/Avalonia (I guees same true for UWP and MAUI), at least there weren't several years ago. Of course, there are several libraries that make usage of MessageBox in WPF possible, even using MaterialDesign ones, but it's not a good approach, plus I'm sure they use same DialogHost under the hood, which is a correct way to output messages in dotnet's GUI. Current DialogHost is used fom MaterialDesignThemes, so I guess something there caused the regression.

UPD. I've ran through some tests on a VM windows, and the issue does not persists with MaterialDesignThemes ver. 4.1.0 and MaterialDesignColors ver. 2.0.1 (I chose these, because latest version of MaterialDesignExtensions references these ones), so yeah, it seems like a bug on their side

Gigas002 commented 1 year ago

OK, I found out the source of regression, it's in 4.3.0 version. I managed to fix the issue in GTiff2Tiles and will commit the changes soon