Sparkle isn't multi-thread safe

KinemeCore uses a heavily modified version of Sparkle to update plugins. However, I've been suspecting that it's making mistakes for a while. Today, with the release of GLTools 20071119, I've been able to demonstrate this suspicion.

Looks like even more modifications are in order... sigh Sparkle 2 can't come soon enough...

cwright's picture
more problems

I've spent a fair amount of time trying to work around this problem today... with no success.

Sparkle isn't thread safe, and to compound it, neither was a small piece of code that I had added to it.

First, I tried replacing this piece with a thread-local-storage version, only to find that Sparkle performs some selectors on the Main thread, invalidating this method.

Next, I tried single-threading the whole thing. This doesn't work either though (the downloader still spins off a background thread). To attempt to remedy this, I tried locking the global part, with the downloader's completion releasing the lock. This doesn't work because the main thread blocks when it hits the locked lock, and then UI pieces magically stop responding.

Following that, I tried threading the updater portion, to prevent the main thread from getting blocked (since it was beachballing). This allows the UI to respond, but prevents the information window from displaying for whatever reason. From the logs, I also see that it's releasing stuff way before it should. Finally something I can easily fix.

As it stands now, auto-update kind of works finally, but the information window doesn't update for whatever reason (even when allowing all the internal threads again, with proper guarding).

So while this works for now, I'm fairly convinced that Sparkle simply isn't designed for this kind of problem. Does anyone know of any other appcast-capable software update libraries?

[update: the window update failure is probably due to the main thread still trying to spin off more threads? need to investigate this. This is starting to look more and more like spaghetti... I hate it]

[update2: replaced the performSelectorOnMainThread junk (since it's not getting blocked anymore), and now we have info again. So I guess the crisis is averted for now, but I'm still totally up for a better solution if one's out there...]