Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sparkle Test App Fails to Relaunch #525

Closed
zorgiepoo opened this issue Apr 18, 2015 · 8 comments
Closed

Sparkle Test App Fails to Relaunch #525

zorgiepoo opened this issue Apr 18, 2015 · 8 comments

Comments

@zorgiepoo
Copy link
Member

The test app does not relaunch after updating on my Mac. I traced down the problem and it's due to: a7d11f8 (Issue #508)

Commenting out the registration call makes the test app wore properly. Or if I add a sleep(10) after the launch service registration call, the app will relaunch. Apparently it takes some time for LaunchServices to update the app, not allowing Sparkle to re-launch it immediately? Perhaps the app should make the call after it's launched.

Possibly related to issue #459

@zorgiepoo
Copy link
Member Author

Looks like if I substitute the -[NSWorkSpace openFile:] call with a NSTask invoking open it works, but this is really odd.. The process seems to think the executable for the app does not exist (NSBundle's executablePath returns nil for the app, but the executable file does exist).

@michelf
Copy link
Contributor

michelf commented Apr 19, 2015

Not sure if that's related to this problem, but note that NSBundle cache values. If an NSBundle instance exists for a given path, the same instance is reused for the same path later on. If you swap it for something different in the file system, most properties of the bundle will keep their previous values. I discovered that a while ago and wrote about the problem it caused me and its solution.

Should keep this in mind while writing an updater.

@zorgiepoo
Copy link
Member Author

Calling _CFBundleFlushBundleCaches actually does make the app open, but it doesn't open in the foreground. I was familiar with bundle caching but didn't know such a function existed; good to know!

I'm still thinking an open task like how the package installer works might be the best idea currently rather than a private API.

@michelf
Copy link
Contributor

michelf commented Apr 19, 2015

Indeed, it probably is more robust to call open than to rely on a private API.

@kornelski
Copy link
Member

Perhaps it would be safest to call registerWithLaunchServices couple of seconds after relaunch of the app?

@zorgiepoo
Copy link
Member Author

Regarding the test app not showing its dialog window in the foreground, I have a feeling that might have to do with the way the test application is written. The source code to the test app (after you update it) is not available to my knowledge.

[edit]: If you manually download the updated version of the test app, and get past the quarantine dialog, you will notice the app doesn't come in the foreground. (Although, in another case Sparkle is using /usr/bin/open for launching a package installer to make sure it shows as the frontmost app).

If this issue is directly related to issue #459 and this can happen in other cases, then calling the function after the app has been relaunched may not resolve it.

Forgot to mention: executing /usr/bin/touch app (to update the modification time of the app), would also run into same issues as using LSRegisterURL

@kornelski
Copy link
Member

The source code to the test app (after you update it) is not available to my knowledge.

Sorry! Fixed that in b02a659

@kornelski
Copy link
Member

For now I've reverted LSRegisterURL. It'll require another approach :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants