NetSparkle icon indicating copy to clipboard operation
NetSparkle copied to clipboard

Netsparkle download the files synchronously and freezes the UI

Open AMohamedFawzy opened this issue 2 years ago • 7 comments

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

AMohamedFawzy avatar Jul 31 '22 15:07 AMohamedFawzy

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

Deadpikle avatar Jul 31 '22 15:07 Deadpikle

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
  • library: NetSparkleUpdater.UI.Avalonia, version: 2.1.2
  • Avalonia version: 0.10.17
  • .Net version: 6.0.302
  • Sparkle setup:
var uiFactory = new NetSparkleUpdater.UI.Avalonia.UIFactory(new WindowIcon(icon))
{
    HideSkipButton = true
};

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 avatar Jul 31 '22 15:07 AMohamedFawzy

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

AMohamedFawzy avatar Aug 01 '22 17:08 AMohamedFawzy

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.

david-szabo97 avatar Sep 01 '22 12:09 david-szabo97

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 avatar Sep 01 '22 12:09 Deadpikle

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.

Deadpikle avatar Sep 28 '22 01:09 Deadpikle

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

david-szabo97 avatar Sep 30 '22 09:09 david-szabo97

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

Deadpikle avatar Oct 23 '22 21:10 Deadpikle