Under The Microscope

The Finder Really Should Prevent Moving Running Applications

Apple can fix this for everyone, and probably should.

Yesterday, I wrote about how our software works to avoid issues if the application is moved while its in use. We shared some code for this which could be useful to other Mac developers, and Daniel Jalkut produced a more robust drop-in, which all Mac developers should check out.

Our products have handled this issue well enough for many years, and we were generally content with our solution. However, due to changes made in MacOS 10.15 (Catalina), we recently had to dumb down our approach. For years we used GCD (dispatch) to observe the application’s folder, as well as parent folders, to see if they moved. This doesn’t work very well on Catalina, where if the application is residing in the Downloads folder, the OS thinks the user needs to be warned we are “accessing” the Downloads area. To avoid frightening users with unnecessary security dialogs, our solution is now less robust than it once was.

After discussing all of this with Daniel, we came to the realization that this really isn’t something individual developers ought to need to handle at all. Instead, it makes the most sense for Apple to help users avoid this issue at the Finder level.

As much as one might want to move a running application, Apple’s Cocoa framework is simply is unable to correctly handle the situation at present. This leads to unexpected application behaviors and even crashes. To avoid these issues, the Finder already works to avoid multiple types of changes to running applications. For instance, if you try to delete an application that’s open, the Finder stops you:

As well, if you attempt to rename an open application, the Finder will warn against it:

This dialog allows you to proceed with the rename (and even makes that action the default), but it at least provides a warning that this action is not be advisable.

However, while any Unix geek can tell you that a rename is really just a move by another name, the Finder does nothing to stop you from actually moving the app. This seems like a real oversight, and something that can and should be fixed on Apple’s end.

I opted to file a bug with Apple about this (#FB7216674). Perhaps developers will one day see the Finder handling this for us.

Avoiding Crashes Caused by Application Moves

Moving running apps is a bad idea, but it can be coded around.

One of the best RSS readers on the Mac, NetNewsWire, has returned home to its original developer Brent Simmons. Late last month, Brent and his team of volunteers shipped version 5, and I’m delighted to see the return of NetNewsWire on the Mac.

Along with the release, Brent has been posting frequently to his blog at inessential.com. While discussing a piece he’d published on post-release follow-through, Brent noted “I keep remembering that I know things that I figure everyone knows — but then I remember that they don’t. So I write ’em up”.

This is a noble practice, and it’s inspired our own post, where we’ll be sharing some information and code.

Avoiding Crashes Due to Moved Applications

Following the release of NetNewsWire 5.0.0, Brent discovered the application had a crashing bug. Working with Daniel Jalkut of Red Sweater, they determined that the problem occurred when the application was moved in the Finder. When I saw Brent’s post detailing this issue, I knew we could help.

For many years, Rogue Amoeba’s applications have guarded against this very issue. If one of our applications is moved while it’s running, it will display an error like this:

This alert lets the user know they’re likely to run into issues, and urges them to quit and relaunch.1

Sample Code and Details

I discussed this issue with Daniel and Brent, and provided them with the code we’d been using to watch for this issue. This actually led us to make several changes and tweaks, and a simplified implementation of this “Application Moved” watcher can be found below:

- (void)_showBundleMovedAlertIfNeeded
{
    //This depends on bundleURL being cached and not updated when the app moves
    //Perhaps someday that will be false, but it's true now - 2019-09


    if( [[[NSBundle mainBundle] bundleURL] checkResourceIsReachableAndReturnError: nil] )
        return;

    NSString *appname = [[NSProcessInfo processInfo] processName];
    NSString *messageFmt = @"%@ has been moved or renamed";
    NSString *infoFmt = @"To prevent errors, %@ must be relaunched.\n\nIf you cannot quit immediately, click Continue, then quit and relaunch as soon as possible to avoid problems.";

    NSAlert *alert = [[NSAlert alloc] init];
    [alert setAlertStyle:NSAlertStyleCritical];
    [alert setMessageText:[NSString stringWithFormat:messageFmt, appname]];
    [alert setInformativeText:[NSString stringWithFormat:infoFmt, appname]];
    [alert addButtonWithTitle:@"Quit"];
    [alert addButtonWithTitle:@"Continue (Not Recommended)"];
    
    NSInteger alertButton = [alert runModal];
    [alert release];
    
    if (alertButton == NSAlertFirstButtonReturn)
        [NSApp terminate: self];
}

- (void)applicationDidBecomeActive:(NSNotification *)notification
{
    [self _showBundleMovedAlertIfNeeded];
}

This code was inspired by changes from Daniel, as well as Rich Siegel of Bare Bones. Whenever the application becomes active, we look if the bundle still exists where it should be, and throw an alert if not. This implementation is by no means perfect. For instance, if the application is moved and not activated for awhile, it could fail to notify the user before a problem hits. On the other hand, it gracefully handles other difficult edge cases, like the parent folder of the application being moved.

This is part of the shared code we use in all our applications, so improving it in one place will benefit all of our products. It’s good to revisit and refine things over time, and sharing this code with others has provided us with a nice opportunity to do so.

Closing

If you’re a Mac developer, you might have just realized why some previously inexplicable crashes have been occurring. With the above, you’re well on your way to handling the issue and avoiding crashes.

Over nearly 17 years of developing software for the Mac, we’ve created a lot of useful internal systems and generated a great deal of institutional knowledge. It’s good to be reminded that this accumulated knowledge can help other developers too. We’ll be keeping an eye out for more things we might share with other Mac developers.


Footnotes:

  1. It’s likely that most applications should simply force the user to quit, but as you can see, we also provide a “Continue” option. For our applications, the user may be in the middle of an important and uninterruptible task, like making a recording, so we don’t want to force them to quit the application. ↩︎

Hear All About Us: SoundSource’s Honors and More

A Rave Review for SoundSource

2019 has featured major updates to our sound control utility SoundSource, with version 4.0 shipping at the end of March, and a major update to version 4.1 two months later. These updates have been met with much acclaim, and now Macworld has named SoundSource an “Editor’s Choice”, as part of a near-perfect 4.5/5 mice review.

If you haven’t checked out SoundSource yet, now’s a great time to see the app Macworld calls “a must-have utility”.

Company Profile

I recently took part in an in-depth interview about our products and our history with the folks at HostingAdvice. The result is a fine profile of our company, which touches on both our software products and our philosophy about software development in general. Click to give it a read.

The Mac Quadcast

Finally, I also recently spoke with Darren Carr on his show “The Mac Quadcast”. We discussed my own background, Rogue Amoeba’s work, and the amazing “Voice Control” system coming to Apple’s devices. Check out episode #24 of the Mac Quadcast right here.

Get Dark Mode Support and Much More, in SoundSource 4.1

SoundSource 4.1 is here, with dark mode support and much more!

If you use audio in any way on your Mac, our newest app SoundSource is for you. With it, you can control audio on a per-app level, add effects to any audio, boost sound from even the tiniest MacBook speakers, and gain fast access to your Mac’s audio devices.

After we released SoundSource 4.0 in March, we received a lot of great customer feedback. We kept these requests and ideas in mind as we continued development. Today, we’re shipping a major update in the form of SoundSource 4.1. This new version adds several features, squashes a large number of bugs, and improves the app in ways both big and small.

Big Changes, Tucked in the Preferences

The two biggest changes in SoundSource 4.1 can be found in the new “Appearance” section of the Preferences window:


SoundSource’s new Appearance preferences

Dark Mode Support

The most striking change is certainly the optional new Dark appearance:


SoundSource’s new Dark Mode appearance

Use the default “Match System” setting, and SoundSource will follow your OS-wide appearance.1 If you prefer, you can force SoundSource to use the “Light” or “Dark” theme, regardless of your system-wide settings.

Output Volume in Menu Bar

The other major appearance change comes via a simple checkbox. Turn on the “Show output volume in menu bar” preference, and SoundSource’s default menu bar icon will be replaced with a volume indicator.

This icon helpfully displays a simplified approximation of the current output volume, and even indicates when your output device is entirely muted. With this, you no longer need the system Volume control in the menubar at all.

Easier Control of Special Audio Sources

We heard from users who wanted to adjust and control audio in the Finder, as well as the OS’s “Text to Speech” functionality. That’s now possible with SoundSource 4.1, as these sources are now easily selected from the new “Special Sources” section found in the “Add App” Source selector.

Smaller Updates

There are also many smaller updates to appreciate as well. These include:

  • Full Undo Support – SoundSource now includes full Undo support, so you can revert any changes you make to settings. Just hit Command (⌘)-Z on your keyboard to undo your most recent change.

  • Audio Effects Indicator – SoundSource now shows a helpful “FX” badge to indicate when a source is being modified by audio effects.

  • Right-Click Menu Bar Menu – A standard click on SoundSource’s menu bar icon reveals the app’s main window. Now, a right-click will show a helpful menu giving you quick access to SoundSource’s settings, or a fast way to quit the app.

  • Enhancements and Refinements Galore – We worked tirelessly to provide a worthy follow-up to SoundSource 4’s auspicious debut. This update includes over 30 distinct improvements, from better handling of Bluetooth devices to a more-obvious background state, and much, much more.

Critical Bug Fixes

Older versions of SoundSource had several issues which could cause the app to pinwheel or even crash. These issues were fortunately quite rare, but that also made them difficult to track down. After some deep debugging, we believe we’ve eliminated these problems. We strongly encourage all users to update to SoundSource 4.1 immediately for optimal performance. If you see any similar problems in the latest version, be sure to get in touch.

Get It Right Now

SoundSource 4.1 now represents the latest and greatest in sound control for your Mac, and we can’t wait for you to try it out. Users who already have SoundSource 4 should update to version 4.1 free of charge. Just open the Preferences window in SoundSource, click the “Check for Update” button, and enjoy!

If you’re new to SoundSource, visit our web site to learn all about our superior sound control. You can also download the free trial immediately.


Footnotes:

  1. “Match System” will follow settings found in the General System Preference. On MacOS 10.14 (Mojave), it follows the “Appearance” setting for Light or Dark Mode, while on MacOS 10.13 and lower, it follows the older “Use dark menu bar and Dock” setting. ↩︎

Update to Piezo 1.6 Now

Grab the latest version of Piezo now!

We’ve just posted a fresh update for our charmingly simple audio recorder Piezo, now up to version 1.6. Piezo remains the easiest way to record audio from any application on your Mac, as well as from input devices like microphones. Read on to see what’s changed in our one-click recording tool.

Enhancements in Piezo 1.6

There are several small, but worthwhile, improvements in this update. Most importantly, we’ve worked to make recording even more robust under very heavy loads. Piezo has always worked well even when your CPU is burdened by other tasks, but with this update, even the busiest Mac will produce perfect recordings free from skips or dropouts.

As part of work we’re doing across our product line, we’ve also made small refinements to Piezo’s Source selector. This includes new organization and an enhanced look, as well as an update for the input device icon. These changes and more will be coming to the rest of our line-up soon.

Finally, the Audio Capture Engine (ACE) backend has been updated to version 10.0.1, for the most robust and reliable audio capture. We’re constantly refining and fine-tuning ACE, so be sure you’re running the latest version by checking “Install Extras” in the Piezo menu.

Bug Fixes

This update also fixed a couple small bugs. On MacOS 10.14 (Mojave), Piezo’s popover could get a little…funky. While, the connector should point toward the Gear button, Mojave has some issues which meant that with enough clicking and dragging, you could get the popover looking like this:


The old Piezo, misbehaving on Mojave

Once we discovered this issue, we couldn’t sleep until it was corrected. Thankfully, we were able to work around these Mojave issues, and all is again right with Piezo’s popover:


Piezo 1.6, looking great on Mojave

We also fixed a very rare bug, where some unlucky timing could cause the aforementioned popover to get stuck out of position. Internally, we dubbed this the “wiggle freeze”, as it required a lot of wiggling to make the popover freeze.

We’re not aware of any users actually running in to this issue in the wild, but it’s worth mentioning because it has a fun name.

Update Now

This is a free update for existing users, so if you already own Piezo, just open it up and select “Check for Update” from the Piezo menu to download the latest. If you’ve never used Piezo before, now’s a great time to learn more about it, and download the free trial.

Looking for More Power?

Piezo is incredibly easy to use, but you might be looking for additional features from your recording tool. We’ve got you covered there too, with Piezo’s big brother Audio Hijack. Piezo is great for simple recordings, while Audio Hijack is great for users who need more power.

You can always review our brief comparison between Piezo and Audio Hijack, then download a free trial of both apps to test things out.