OldSquirrelForWindows icon indicating copy to clipboard operation
OldSquirrelForWindows copied to clipboard

UpdateManager hanging and crashing when using progress

Open stefanolson opened this issue 10 years ago • 6 comments

I've had a few the problems when running the update manager when the releases file cannot be found (no internet access etc...). The application hangs trying to download when it doesn't exist ONLY IF progress is set.

Sometimes, when I resize the application I get a crash saying that the update manager needs to be disposed, but the code hasn't finished running (I have a breakpoint on every possible exit + message boxes). Sometimes the application will crash with a web exception, with no stack trace. You can see from the log that it is trying to download it: [INFO][2013-12-01T01:42:56] UpdateManager: Downloading RELEASES file from http://{website}/setup

But as it doesn't currently exist at that address it should just throw an exception or something (Which it does do if you don't pass progress). Sadly it just sits there and hangs - no exception, no nothing.

Running 0.7.4.

My code:

try
{
    using (var updateManager = new UpdateManager(Application.WebServer + "setup",
        "AppName", FrameworkVersion.Net45))
    {
        var progress = new Subject<int>();
        progress.Subscribe((p) => _value = p);

        await updateManager.CheckForUpdate(false,progress);

        MessageBox.Show("got there!");
    }
}
catch (Exception ex)
{
    MessageBox.Show("got ex!");
}

stefanolson avatar Dec 01 '13 01:12 stefanolson

What happens if you enable first-chance exceptions?

anaisbetts avatar Dec 02 '13 02:12 anaisbetts

Still nothing, no exceptions at all :-(

stefanolson avatar Dec 02 '13 02:12 stefanolson

I can reproduce the crash by changing my update URL to https: (which I know will fail), and calling CheckForUpdate(false, progress) as per @stefanolson. (CheckForUpdate() with no progress will not crash.)

I've traced it to line 46 of BitsManager.cs. If I replace

ret.Select(_ => 100).Subscribe(progress);

with

progress.OnNext(100);

my app doesn't crash.

I'm guessing that ret.Select().Subscribe() propagates the captured WebExceptions, which eventually go unhandled?

Not sure if this is an actual bug in Squirrel, but @stefanolson can prevent the crash it by changing his code to

progress.Subscribe(p => _value = p, exception => { /* ignore */ });

bgrainger avatar Dec 04 '13 07:12 bgrainger

@stefanolson: Are you the same Stefan Olson who packaged up my Win32 splash screen? If so: small world, isn't it? (Also, your blog is currently down.)

bgrainger avatar Dec 04 '13 07:12 bgrainger

@bgrainger Yes, I am the same Stefan Olson! The WPF community is sadly very very small and with Microsoft's focus away from the desktop probably not going to get any bigger :-( WPF is just so much more flexible than WinRT or Windows phone which I'm doing most of my other work in these days. I feel like just about every project I work on you have to build for three or four different platforms and they are all Microsoft platforms, with substantial and frustrating differences!

Thanks for letting me know about my blog, I haven't done anything with it for ages. It's probably become overwhelmed with spam.

stefanolson avatar Dec 04 '13 17:12 stefanolson

@bgrainger thanks for the suggestion regarding the web exception. I will give that a go although most of the time I wasn't getting a web exception I was mostly just getting it hanging, but hopefully that will fix that as well

stefanolson avatar Dec 04 '13 17:12 stefanolson