NetSparkleUpdater / NetSparkle

NetSparkle is a C#, cross-platform, highly-configurable software update framework with pre-built UI for .NET developers compatible with .NET 4.6.2/.NET 6+, WinForms, WPF, and Avalonia; uses Ed25519 signatures. View basic usage here in the README and try the samples for yourself.
https://netsparkleupdater.github.io/NetSparkle/
MIT License
606 stars 84 forks source link

Netsparkle download the files synchronously and freezes the UI #359

Closed AMohamedFawzy closed 1 year ago

AMohamedFawzy commented 2 years ago

I used the same code as the netsparkle.sample.avalonia then used a bigger update file (45 megabytes) but the UI hangs until the download finishes

Deadpikle commented 2 years ago

Hi @AMohamedFawzy,

Thank you for the report; however, it would be very helpful if you could create an example and/or say how you are creating your SparkleUpdater instance as well as your .NET version, version of Avalonia, etc., since any of those might help the rest of us replicate and fix any problems that exist.

Please let us know:

AMohamedFawzy commented 2 years ago

Hi @AMohamedFawzy,

Thank you for the report; however, it would be very helpful if you could create an example and/or say how you are creating your SparkleUpdater instance as well as your .NET version, version of Avalonia, etc., since any of those might help the rest of us replicate and fix any problems that exist.

Please let us know:

  • Which library you are using (sounds like NetSparkleUpdater.UI.Avalonia) and which version of the library you are using (e.g. 2.1.2)
  • Your version of Avalonia
  • Your .NET version
  • Your exact setup for creating the SparkleUpdater instance, not including any private URLs or keys or things like that

var sparkle = new SparkleUpdater( "https://example.com/appcast.xml", new Ed25519Checker(SecurityMode.Unsafe, "public key")) { UIFactory = uiFactory, RelaunchAfterUpdate = false, ShowsUIOnMainThread = true, CustomInstallerArguments = "" };

sparkle.StartLoop(true);

AMohamedFawzy commented 2 years ago

I found a workaround (although not elegant), I copied the netsparkle WebClientFileDownloader and modified it like this+

Before:

        public void StartFileDownload(Uri uri, string downloadFilePath)
        {
            _logger?.PrintMessage("IUpdateDownloader: Starting file download from {0} to {1}", uri, downloadFilePath);

            AsyncHelper.RunSync(async () =>
            {
                await StartFileDownloadAsync(uri, downloadFilePath);
            });
        }

After:

        public void StartFileDownload(Uri uri, string downloadFilePath)
        {
            _logger?.PrintMessage("IUpdateDownloader: Starting file download from {0} to {1}", uri, downloadFilePath);
            await StartFileDownloadAsync(uri, downloadFilePath);
        }

for some reason the function was made to run synchronous intentionally freezing the UI, I think this has something to do with avaloniaui being slightly differenet from winforms and WPF

david-szabo97 commented 2 years ago

Experiencing the same issue. When I click on the "Download/Install" button, the window disappears, and the progress window doesn't show until the download is completed. Removing the AsyncHelper.RunSync call fixed the issue.

Deadpikle commented 2 years ago

Hi @david-szabo97, thanks for the confirmation. I am extremely busy right now and don't know when I will get to this, so if anyone wants to send in a PR or figure this one out, I'd be very grateful. At least there is a workaround for the moment. :)

Deadpikle commented 1 year ago

Hi,

Sorry for the wait. Could you try 2.1.3-preview20220927001 (rolling out to NuGet through CI/CD now) and let me know if it works better for you all? Make sure to use the default (built-in) classes rather than anything you've created when testing.

david-szabo97 commented 1 year ago

2.1.3-preview20220927001 works for me, using the default classes. Thank you! Can't wait for the release 😄

Deadpikle commented 1 year ago

Rolling out now in CI/CD in version 2.1.3. Thanks again!